Struct NetworkPacketReceiver
The NetworkPacketReceiver is an interface for handling received packets, needed by the INetwork
- Your API requires a pointer to memory that you own. Then you should use Allocate
Memory(ref int) , write to the memory and then AppendPacket(Int with NoPtr, ref Network Interface End Point, int, Append Packet Mode) Copy . You don't need to deallocate the memoryNeeded - Your API gives you a pointer that you don't own. In this case you should use Append
Packet(Int with None (default)Ptr, ref Network Interface End Point, int, Append Packet Mode)
Inherited Members
Namespace: Unity.Networking.Transport
Assembly: Unity.Networking.Transport.dll
Syntax
public struct NetworkPacketReceiver
Properties
LastUpdateTime
Gets the value of the last update time.
Declaration
public long LastUpdateTime { get; }
Property Value
Type | Description |
---|---|
long |
ReceiveErrorCode
Sets the value of the receive error code
Declaration
public int ReceiveErrorCode { set; }
Property Value
Type | Description |
---|---|
int |
Methods
AllocateMemory(ref int)
Calls NetworkDriver's Allocate
Declaration
public IntPtr AllocateMemory(ref int dataLen)
Parameters
Type | Name | Description |
---|---|---|
int | dataLen | Size of memory to allocate in bytes. Must be > 0 |
Returns
Type | Description |
---|---|
Int |
Pointer to allocated memory or IntPtr.Zero if there is no space left (this function doesn't set Receive |
AppendPacket(IntPtr, ref NetworkInterfaceEndPoint, int, AppendPacketMode)
When data is received this function should be called to pass it inside Network
Declaration
public bool AppendPacket(IntPtr data, ref NetworkInterfaceEndPoint address, int dataLen, NetworkPacketReceiver.AppendPacketMode mode = AppendPacketMode.None)
Parameters
Type | Name | Description |
---|---|---|
Int |
data | Pointer to the data. If it is pointer to data that was received with Allocate |
Network |
address | Address where data was received from |
int | dataLen | Length of data in bytes |
Network |
mode | Extra flags, like No |
Returns
Type | Description |
---|---|
bool | True if no errors |
IsAddressUsed(NetworkInterfaceEndPoint)
Check if an address is currently associated with a valid connection. This is mostly useful to keep interface internal lists of connections in sync with the correct state.
Declaration
public bool IsAddressUsed(NetworkInterfaceEndPoint address)
Parameters
Type | Name | Description |
---|---|---|
Network |
address | Address to check. |
Returns
Type | Description |
---|---|
bool | Whether the address is used or not. |