MessageConfig
MessageConfig
allows you to configure settings for message communication within Tarnet. Settings like message compression and buffer size help manage data transmission efficiently. These configurations are critical for optimizing data size and enhancing performance during transmission.
Properties
compression
Type:
bool
Description: Enables or disables message compression to reduce the size of data during transmission.
What does it do? When enabled, message compression reduces the size of the data being transmitted, which helps optimize bandwidth usage. This is especially useful for projects that frequently transmit large amounts of data, reducing network traffic and improving performance.
How it works: Messages are compressed before being sent and decompressed on the receiving end. This process is handled automatically using compression algorithms.
Default Value:
false
bufferSize
Type:
int
Description: Defines the size of the buffer (in bytes) used for message handling.
What does it do? The buffer size determines the amount of memory allocated for handling messages before they are transmitted or processed. A larger buffer size allows longer messages to be processed in a single operation, but it also increases memory usage.
How it works: Incoming and outgoing messages are processed in the buffer. The buffer size helps prevent large messages from being fragmented and ensures faster processing. However, the buffer size should be adjusted according to the specific requirements of the project.
Default Value:
1024
(1 KB)
How to Create MessageConfig
Through the Unity Editor Navigate to Assets > Create > Tarnet > MessageConfig to create a new
MessageConfig
instance.
Through Code
Usages:
MessageConfig
is configured and used through the SocketBuilder class. Below is an example of how to integrate it using the SetMessageConfig
method:
These configurations ensure maximum efficiency in network communication built with Tarnet. By setting the appropriate values for your project, you can create a faster, more reliable, and optimized communication infrastructure.
Last updated