new Channel(endpoint, channelID)
Parameters:
Name | Type | Description |
---|---|---|
endpoint |
Trap.Endpoint | The endpoint that spawned this channel. |
channelID |
Number | The channel ID being created |
- Source:
Properties:
Name | Type | Description |
---|---|---|
streamingEnabled |
Boolean | Controls the streaming flag of
the channel. When a channel works in streaming mode, it will
dispatch trapData events as data is received, although always in
the correct order. With streaming mode disabled, each trapData
event will represent a single send() event on the other side.
Streaming mode is useful for when Trap is used to transfer larger chunks of data, whose framing is internal to the data transferred. For example, an image, a song, or a video stream. Streaming mode will reduce – but not eliminate – the amount of buffering done in Trap. |
chunkSize |
Integer | The maximum number of bytes allowed in each
message. Note that the chunk size includes the Trap message header,
and this will be automatically subtracted from numBytes,
unless numBytes is in the range of [1, TRAP_HEADER_SIZE]. If
numBytes is zero or negative, chunking will be disabled.
Note that a chunkSize of Integer.MAX_VALUE will disable chunking. A
channel will have that value set if the remote endpoint is
suspected of not supporting chunking. Excepting that, chunkSize
will automatically be reduced to the trap config option
|
maxInFlightBytes |
Integer | The maximum number of in-flight bytes.
Combined with the chunk size, this limits the number of messages
that the channel will allow to be in transit at any given time.
Increasing the number of in flight bytes will increase the required buffer sizes on both the local and remote ends, as well as the system's network buffers. It may also increase throughput, especially on congested links or when using multiple transports. Note that in-flight bytes differs from the queue size. The queue denotes how many messages/bytes this channel can buffer, while in-flight bytes denotes how many messages/bytes we allow on the network. |
priority |
Integer | The channel priority, relative to the other
channels. Channel ID 0 has priority Integer#MAX_VALUE ,
meaning any traffic on 0 takes precedence of any other traffic, for
any reason.
Priority is byte based. A channel with priority n will be allowed to send up to n bytes before ceding transmission rights to a transport with lower priority. Note that if chunkSize exceeds priority, the transport will nevertheless be allowed to send chunkSize number of bytes. Priority only affects the scheduling order of messages, and not the throughput. For the exact buffering, one must consider the channel's in-flight limit, the endpoint's in-flight limit (if any), as well as the transports' in-flight limit. |