Struct NetworkDriver.Concurrent
Structure that can be used to access a NetworkDriver
from multiple jobs. Only a
subset of operations are supported because not all operations are safe to perform
concurrently. Must be obtained with the To
Inherited Members
Namespace: Unity.Networking.Transport
Assembly: Unity.Networking.Transport.dll
Syntax
public struct NetworkDriver.Concurrent
Methods
AbortSend(DataStreamWriter)
Aborts a send started with Begin
Declaration
public void AbortSend(DataStreamWriter writer)
Parameters
Type | Name | Description |
---|---|---|
Data |
writer | Unity. |
BeginSend(NetworkConnection, out DataStreamWriter, int)
Begin sending data on the given connection (default pipeline).
Declaration
public int BeginSend(NetworkConnection connection, out DataStreamWriter writer, int requiredPayloadSize = 0)
Parameters
Type | Name | Description |
---|---|---|
Network |
connection | Connection to send the data to. |
Data |
writer | Unity. |
int | requiredPayloadSize | Size that the returned Unity. |
Returns
Type | Description |
---|---|
int | 0 on success, a negative value on error. |
BeginSend(NetworkPipeline, NetworkConnection, out DataStreamWriter, int)
Begin sending data on the given connection and pipeline.
Declaration
public int BeginSend(NetworkPipeline pipe, NetworkConnection connection, out DataStreamWriter writer, int requiredPayloadSize = 0)
Parameters
Type | Name | Description |
---|---|---|
Network |
pipe | Pipeline to send the data on. |
Network |
connection | Connection to send the data to. |
Data |
writer | Unity. |
int | requiredPayloadSize | Size that the returned Unity. |
Returns
Type | Description |
---|---|
int | 0 on success, a negative error code on error. |
EndSend(DataStreamWriter)
Enqueue a send operation for the data in the given Unity.
Declaration
public int EndSend(DataStreamWriter writer)
Parameters
Type | Name | Description |
---|---|---|
Data |
writer | Unity. |
Returns
Type | Description |
---|---|
int | The number of bytes to be sent on success, a negative value on error. |
Remarks
This method doesn't actually send anything on the wire. It simply enqueues the send
operation, which will be performed in the next Schedule
GetConnectionState(NetworkConnection)
Get the current state of the given connection.
Declaration
public NetworkConnection.State GetConnectionState(NetworkConnection id)
Parameters
Type | Name | Description |
---|---|---|
Network |
id |
Returns
Type | Description |
---|---|
Network |
State of the connection. |
MaxHeaderSize(NetworkPipeline)
Get the maximum size of headers when sending on the given pipeline.
Declaration
public int MaxHeaderSize(NetworkPipeline pipe)
Parameters
Type | Name | Description |
---|---|---|
Network |
pipe | Pipeline to get the header size for. |
Returns
Type | Description |
---|---|
int | The maximum size of the headers on the given pipeline. |
Remarks
Only accounts for the Unity Transport headers (no UDP or IP).
PopEventForConnection(NetworkConnection, out DataStreamReader)
Pops the next event from the event queue for the given connection, Empty will be returned if there are no more events.
Declaration
public NetworkEvent.Type PopEventForConnection(NetworkConnection connection, out DataStreamReader reader)
Parameters
Type | Name | Description |
---|---|---|
Network |
connection | Connection for which to pop the event. |
Data |
reader | Unity. |
Returns
Type | Description |
---|---|
Network |
The type of the event popped. |
Remarks
The reader
obtained from this method will contain different things for different
event types. For Data, it contains the actual received
payload. For Disconnect, it contains a single byte
identifying the reason for the disconnection (see Disconnect
PopEventForConnection(NetworkConnection, out DataStreamReader, out NetworkPipeline)
Pops the next event from the event queue for the given connection, Empty will be returned if there are no more events.
Declaration
public NetworkEvent.Type PopEventForConnection(NetworkConnection connection, out DataStreamReader reader, out NetworkPipeline pipe)
Parameters
Type | Name | Description |
---|---|---|
Network |
connection | Connection for which to pop the event. |
Data |
reader | Unity. |
Network |
pipe | Pipeline on which the data event was received. |
Returns
Type | Description |
---|---|
Network |
The type of the event popped. |
Remarks
The reader
obtained from this method will contain different things for different
event types. For Data, it contains the actual received
payload. For Disconnect, it contains a single byte
identifying the reason for the disconnection (see Disconnect