Photon Fusion 2.0.3

Classes | Public Types | Public Member Functions | Static Public Member Functions | Public Attributes | Properties | List of all members
NetConnectionMap Struct Reference

Represents a network connection map. More...

Classes

struct  Iterator
 Iterator for traversing the connections in a NetConnectionMap. More...
 

Public Types

enum class  EntryState
 Represents the state of an entry in the NetConnectionMap. More...
 

Public Member Functions

NetConnectionFind (NetAddress address)
 Finds a connection by its address in the network peer group. More...
 
NetConnectionFind (NetConnectionId id)
 Finds a connection by its ID in the network peer group. More...
 
NetConnectionFindByIndex (int index)
 Gets a connection by its index in the network peer group. More...
 
NetConnectionInsert (NetAddress address, byte[] uniqueId)
 Inserts a new connection into the network peer group using the specified address and unique ID. More...
 
NetConnectionRemap (NetAddress oldAddress, NetAddress newAddress)
 Remaps a connection from an old address to a new address. More...
 
bool Remove (NetAddress address)
 Removes a connection from the network peer group by its address. More...
 
bool TryFindByIndex (int index, out NetConnection *connection)
 Tries to get a connection by its index in the network peer group. More...
 

Static Public Member Functions

static NetConnectionMapAllocate (int capacity, short groupIndex, in NetConfig *config)
 Allocates and initializes a new NetConnectionMap with the specified capacity and group index. More...
 
static void Dispose (NetConnectionMap *map, INetPeerGroupCallbacks callbacks)
 Disposes of the specified NetConnectionMap and its associated resources. More...
 

Public Attributes

NetConnection ** Buckets
 
ulong CapacityAllocated
 
ulong FreeCount
 
NetConnectionFreeHead
 
short Group
 
ulong IdsCount
 
UniqueIdMapping * UniqueIdHashes
 
ulong UsedCount
 

Properties

NetConnectionConnectionsBuffer [get]
 Gets the buffer of connections. More...
 
int Count [get]
 Gets the count of used connections minus the free connections. More...
 
int CountUsed [get]
 Gets the count of used connections. More...
 
bool Full [get]
 Gets a value indicating whether the connection map is full. More...
 

Detailed Description

Represents a network connection map.

Member Enumeration Documentation

◆ EntryState

enum EntryState
strong

Represents the state of an entry in the NetConnectionMap.

Enumerator
None 

The entry is not in use.

Free 

The entry is free and available for use.

Used 

The entry is currently in use.

Member Function Documentation

◆ Allocate()

static NetConnectionMap* Allocate ( int  capacity,
short  groupIndex,
in NetConfig config 
)
static

Allocates and initializes a new NetConnectionMap with the specified capacity and group index.

Parameters
capacityThe number of connections the map can hold.
groupIndexThe group index associated with the connections.
configThe configuration settings for the network connections.
Returns
A pointer to the newly allocated NetConnectionMap.

◆ Dispose()

static void Dispose ( NetConnectionMap map,
INetPeerGroupCallbacks  callbacks 
)
static

Disposes of the specified NetConnectionMap and its associated resources.

Parameters
mapA pointer to the NetConnectionMap to dispose.
callbacksThe callbacks to invoke during disposal.

◆ Find() [1/2]

NetConnection* Find ( NetAddress  address)

Finds a connection by its address in the network peer group.

Parameters
addressThe address of the connection to find.
Returns
A pointer to the connection if found, otherwise null.

◆ Find() [2/2]

Finds a connection by its ID in the network peer group.

Parameters
idThe ID of the connection to find.
Returns
A pointer to the connection if found, otherwise null.

◆ FindByIndex()

NetConnection* FindByIndex ( int  index)

Gets a connection by its index in the network peer group.

Parameters
indexThe index of the connection to retrieve.
Returns
A pointer to the connection if found, otherwise throws an IndexOutOfRangeException.
Exceptions
IndexOutOfRangeExceptionThrown when the index is out of the usable capacity range.

◆ Insert()

NetConnection* Insert ( NetAddress  address,
byte[]  uniqueId 
)

Inserts a new connection into the network peer group using the specified address and unique ID.

Parameters
addressThe address of the connection to insert.
uniqueIdThe unique ID of the connection to insert.
Returns
A pointer to the newly inserted connection, or null if the connection is already in use or the capacity is full.

◆ Remap()

NetConnection* Remap ( NetAddress  oldAddress,
NetAddress  newAddress 
)

Remaps a connection from an old address to a new address.

Parameters
oldAddressThe old address of the connection.
newAddressThe new address of the connection.
Returns
A pointer to the remapped connection, or null if the remapping failed.

◆ Remove()

bool Remove ( NetAddress  address)

Removes a connection from the network peer group by its address.

Parameters
addressThe address of the connection to remove.
Returns
True if the connection was successfully removed, otherwise false.

◆ TryFindByIndex()

bool TryFindByIndex ( int  index,
out NetConnection connection 
)

Tries to get a connection by its index in the network peer group.

Parameters
indexThe index of the connection to retrieve.
connectionOutput parameter that will point to the connection if found.
Returns
True if the connection was found, otherwise false.

Property Documentation

◆ ConnectionsBuffer

NetConnection* ConnectionsBuffer
get

Gets the buffer of connections.

◆ Count

int Count
get

Gets the count of used connections minus the free connections.

◆ CountUsed

int CountUsed
get

Gets the count of used connections.

◆ Full

bool Full
get

Gets a value indicating whether the connection map is full.