Photon Fusion 2.0.4

Static Public Member Functions | Public Attributes | Static Public Attributes | Properties | List of all members
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. More...
 
static void DestroySocket (NetPeer *p, INetSocket socket, INetPeerGroupCallbacks callbacks)
 
static short FindGroupWithLeastAssignedAddresses (NetPeer *p)
 
static NetConfigGetConfigPointer (NetPeer *p)
 Gets a pointer to the configuration settings of the specified NetPeer. More...
 
static NetPeerGroupGetGroup (NetPeer *p, int index)
 Gets a pointer to the NetPeerGroup at the specified index. More...
 
static NetPeerInitialize (NetConfig config, INetSocket socket)
 Initializes a new instance of the NetPeer structure with the specified configuration and socket. More...
 
static void Initialize (NetPeer *p, NetConfig config, INetSocket socket)
 Initializes the specified NetPeer instance with the given configuration and socket. More...
 
static void Recv (NetPeer *p, INetSocket socket, bool *work, System.Random rng)
 Receives data for the specified NetPeer and indicates whether work was done. More...
 
static void Recv (NetPeer *p, INetSocket socket, System.Random rng)
 Receives data for the specified NetPeer. More...
 
static bool RecvBufferAvailable (NetPeer *p)
 
static void RecvBufferPushToGroup (NetPeer *p, INetSocket socket, Random rng)
 
static bool RecvExpired (NetPeer *p)
 
static void RecvInternal (NetPeer *p, INetSocket socket, bool *work, System.Random rng)
 
static void RemapAddress (NetPeer *p, NetAddress oldAddress, NetAddress newAddress)
 Remaps the network address of the specified NetPeer. More...
 
static void Send (NetPeer *p, INetSocket socket)
 Sends data for the specified NetPeer. More...
 
static void Send (NetPeer *p, INetSocket socket, bool *work)
 Sends data for the specified NetPeer and indicates whether work was done. More...
 
static void SendFromStack (NetPeer *p, INetSocket socket, bool *work)
 
static void SendInternal (NetPeer *p, INetSocket socket, bool *work)
 
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. More...
 
static void Update (NetPeer *p, INetSocket socket, System.Random rng)
 Updates the state of the specified NetPeer. More...
 

Public Attributes

NetAddress _address
 
NetConfig _config
 
byte * _fragmentBuffer
 
NetPeerGroup_groups
 
int * _groupsAssigned
 
NetPeerGroupMap * _groupsMap
 
NetBitBuffer_recv
 
NetBitBufferBlock * _recvBlock
 
Timer _recvTimer
 
NetCommandRefused_refusedCommand
 
NetBitBufferStack _sendStack
 
volatile int _state
 

Static Public Attributes

const int DEFAULT_HEADERS = 40 + 8 + 96
 IPv6 header: 40 bytes, UDP header: 8 bytes, Realtime Header: 96 bytes More...
 
const int MAX_MTU_BITS_PAYLOAD = MAX_MTU_BYTES_PAYLOAD * 8
 MaximumTransferUnit bits. (ipv6 header: 40 bytes, udp header: 8 bytes) More...
 
const int MAX_MTU_BYTES_PAYLOAD = MAX_MTU_BYTES_TOTAL - DEFAULT_HEADERS
 MaximumTransferUnit payload bytes. More...
 
const int MAX_MTU_BYTES_TOTAL = 1280
 MaximumTransferUnit total bytes. More...
 
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) More...
 
const int MAX_PACKET_BYTES_TOTAL = MAX_MTU_BYTES_TOTAL * FRAG_MAX_COUNT
 Max packet total size in bytes. More...
 
const int STATE_RUNNING = 0
 
const int STATE_SHUTDOWN = 2
 

Properties

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

Detailed Description

Network Peer

Member Function Documentation

◆ Destroy()

static 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()

static 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()

static 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]

static 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]

static 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]

static 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]

static 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()

static 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]

static void 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.

◆ Send() [2/2]

static void 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.

◆ Update() [1/2]

static 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]

static 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

◆ DEFAULT_HEADERS

const int DEFAULT_HEADERS = 40 + 8 + 96
static

IPv6 header: 40 bytes, UDP header: 8 bytes, Realtime Header: 96 bytes

◆ 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.

Property Documentation

◆ Address

NetAddress Address
get

Gets the network address of the peer.

◆ Config

NetConfig Config
get

Gets the configuration settings for the peer.

◆ GroupCount

int GroupCount
get

Gets the number of connection groups.

◆ IsShutdown

bool IsShutdown
get

Gets a value indicating whether the peer is shut down.