Photon Fusion 2.1.1

NetPeer Struct Reference

Network Peer. More...

Static Public Member Functions

static void Destroy (NetPeer *p, INetSocket socket, INetPeerGroupCallbacks callbacks)
 Destroys the specified NetPeer instance and releases associated resources.
static NetConfigGetConfigPointer (NetPeer *p)
 Gets a pointer to the configuration settings of the specified NetPeer.
static NetPeerGroupGetGroup (NetPeer *p, int index)
 Gets a pointer to the NetPeerGroup at the specified index.
static NetPeerInitialize (NetConfig config, INetSocket socket)
 Initializes a new instance of the NetPeer structure with the specified configuration and socket.
static void Initialize (NetPeer *p, NetConfig config, INetSocket socket)
 Initializes the specified NetPeer instance with the given configuration and socket.
static void Recv (NetPeer *p, INetSocket socket, bool *work, System.Random rng)
 Receives data for the specified NetPeer and indicates whether work was done.
static void Recv (NetPeer *p, INetSocket socket, System.Random rng)
 Receives data for the specified NetPeer.
static void RemapAddress (NetPeer *p, NetAddress oldAddress, NetAddress newAddress)
 Remaps the network address of the specified NetPeer.
static int Send (NetPeer *p, INetSocket socket)
 Sends data for the specified NetPeer.
static int Send (NetPeer *p, INetSocket socket, bool *work)
 Sends data for the specified NetPeer and indicates whether work was done.
static int SendFromStack (NetPeer *p, INetSocket socket, bool *work)
 
Returns
The amount of fragments sent

static int SendInternal (NetPeer *p, INetSocket socket, bool *work)
 
Returns
The amount of fragments sent

static void Update (NetPeer *p, INetSocket socket, bool *work, System.Random rng)
 Updates the state of the specified NetPeer and indicates whether work was done.
static void Update (NetPeer *p, INetSocket socket, System.Random rng)
 Updates the state of the specified NetPeer.

Static Public Attributes

const int DEFAULT_HEADERS = 40 + 8 + 96
 IPv6 header: 40 bytes, UDP header: 8 bytes, Realtime Header: 96 bytes.
const int MAX_MTU_BITS_PAYLOAD = MAX_MTU_BYTES_PAYLOAD * 8
 MaximumTransferUnit bits. (ipv6 header: 40 bytes, udp header: 8 bytes).
const int MAX_MTU_BYTES_PAYLOAD = MAX_MTU_BYTES_TOTAL - DEFAULT_HEADERS
 MaximumTransferUnit payload bytes.
const int MAX_MTU_BYTES_TOTAL = 1280
 MaximumTransferUnit total bytes.
const int MAX_PACKET_BYTES_PAYLOAD = (MAX_MTU_BYTES_PAYLOAD - NetNotifyHeader.SIZE_IN_BYTES) * FRAG_MAX_COUNT
 Max packet payload size in bytes. (Considering the NetNotifyHeader size for each fragment).
const int MAX_PACKET_BYTES_TOTAL = MAX_MTU_BYTES_TOTAL * FRAG_MAX_COUNT
 Max packet total size in bytes.

Properties

readonly NetAddress Address [get]
 Gets the network address of the peer.
readonly NetConfig Config [get]
 Gets the configuration settings for the peer.
readonly int GroupCount [get]
 Gets the number of connection groups.
readonly bool IsShutdown [get]
 Gets a value indicating whether the peer is shut down.

Detailed Description

Network Peer.

Member Function Documentation

◆ Destroy()

void Destroy ( NetPeer * p,
INetSocket socket,
INetPeerGroupCallbacks callbacks )
static

Destroys the specified NetPeer instance and releases associated resources.

Parameters
pA pointer to the NetPeer instance.
socketThe socket used for network communication.
callbacksThe callbacks for the NetPeerGroup.

◆ GetConfigPointer()

NetConfig * GetConfigPointer ( NetPeer * p)
static

Gets a pointer to the configuration settings of the specified NetPeer.

Parameters
pA pointer to the NetPeer instance.
Returns
A pointer to the NetConfig if the peer is not shut down; otherwise, null.

◆ GetGroup()

NetPeerGroup * GetGroup ( NetPeer * p,
int index )
static

Gets a pointer to the NetPeerGroup at the specified index.

Parameters
pA pointer to the NetPeer instance.
indexThe index of the NetPeerGroup.
Returns
A pointer to the NetPeerGroup if the peer is not shut down; otherwise, null.

◆ Initialize() [1/2]

NetPeer * Initialize ( NetConfig config,
INetSocket socket )
static

Initializes a new instance of the NetPeer structure with the specified configuration and socket.

Parameters
configThe configuration settings for the NetPeer.
socketThe socket used for network communication.
Returns
A pointer to the newly initialized NetPeer instance.

◆ Initialize() [2/2]

void Initialize ( NetPeer * p,
NetConfig config,
INetSocket socket )
static

Initializes the specified NetPeer instance with the given configuration and socket.

Parameters
pA pointer to the NetPeer instance.
configThe configuration settings for the NetPeer.
socketThe socket used for network communication.

◆ Recv() [1/2]

void Recv ( NetPeer * p,
INetSocket socket,
bool * work,
System.Random rng )
static

Receives data for the specified NetPeer and indicates whether work was done.

Parameters
pA pointer to the NetPeer instance.
socketThe socket used for network communication.
workA pointer to a boolean indicating whether work was done.
rngA random number generator.

◆ Recv() [2/2]

void Recv ( NetPeer * p,
INetSocket socket,
System.Random rng )
static

Receives data for the specified NetPeer.

Parameters
pA pointer to the NetPeer instance.
socketThe socket used for network communication.
rngA random number generator.

◆ RemapAddress()

void RemapAddress ( NetPeer * p,
NetAddress oldAddress,
NetAddress newAddress )
static

Remaps the network address of the specified NetPeer.

Parameters
pA pointer to the NetPeer instance.
oldAddressThe old network address.
newAddressThe new network address.

◆ Send() [1/2]

int Send ( NetPeer * p,
INetSocket socket )
static

Sends data for the specified NetPeer.

Parameters
pA pointer to the NetPeer instance.
socketThe socket used for network communication.
Returns
The amount of fragments sent

◆ Send() [2/2]

int Send ( NetPeer * p,
INetSocket socket,
bool * work )
static

Sends data for the specified NetPeer and indicates whether work was done.

Parameters
pA pointer to the NetPeer instance.
socketThe socket used for network communication.
workA pointer to a boolean indicating whether work was done.
Returns
The amount of fragments sent

◆ Update() [1/2]

void Update ( NetPeer * p,
INetSocket socket,
bool * work,
System.Random rng )
static

Updates the state of the specified NetPeer and indicates whether work was done.

Parameters
pA pointer to the NetPeer instance.
socketThe socket used for network communication.
workA pointer to a boolean indicating whether work was done.
rngA random number generator.

◆ Update() [2/2]

void Update ( NetPeer * p,
INetSocket socket,
System.Random rng )
static

Updates the state of the specified NetPeer.

Parameters
pA pointer to the NetPeer instance.
socketThe socket used for network communication.
rngA random number generator.

Member Data Documentation

◆ MAX_MTU_BITS_PAYLOAD

const int MAX_MTU_BITS_PAYLOAD = MAX_MTU_BYTES_PAYLOAD * 8
static

MaximumTransferUnit bits. (ipv6 header: 40 bytes, udp header: 8 bytes).

Same as MAX_MTU_BYTES_PAYLOAD but in bits.

◆ MAX_MTU_BYTES_PAYLOAD

const int MAX_MTU_BYTES_PAYLOAD = MAX_MTU_BYTES_TOTAL - DEFAULT_HEADERS
static

MaximumTransferUnit payload bytes.

The maximum number of bytes available for data(payload) in a single UDP packet.

◆ MAX_MTU_BYTES_TOTAL

const int MAX_MTU_BYTES_TOTAL = 1280
static

MaximumTransferUnit total bytes.

The maximum size of bytes that can be sent in a single UDP packet.

◆ MAX_PACKET_BYTES_PAYLOAD

const int MAX_PACKET_BYTES_PAYLOAD = (MAX_MTU_BYTES_PAYLOAD - NetNotifyHeader.SIZE_IN_BYTES) * FRAG_MAX_COUNT
static

Max packet payload size in bytes. (Considering the NetNotifyHeader size for each fragment).

The maximum number of bytes available for data that can be fragmented into multiple packets of size MAX_MTU_BYTES_PAYLOAD.

◆ MAX_PACKET_BYTES_TOTAL

const int MAX_PACKET_BYTES_TOTAL = MAX_MTU_BYTES_TOTAL * FRAG_MAX_COUNT
static

Max packet total size in bytes.

The maximum number of bytes that can be fragmented into multiple packets of size MAX_MTU_BYTES_TOTAL.