Table of Contents

Class ConnectionExtensions

Namespace
BSGameLib.Server
Assembly
BSGameLib.Server.dll

Extension methods that act on a connection through a session registry.

public static class ConnectionExtensions
Inheritance
ConnectionExtensions
Inherited Members

Methods

Disconnect<TSessionId>(IListenSocket, TSessionId, IConnectionRegistry<TSessionId>, string)

Disconnects the connection mapped to sessionId in the registry. No-ops if the session ID is not bound.

public static void Disconnect<TSessionId>(this IListenSocket socket, TSessionId sessionId, IConnectionRegistry<TSessionId> registry, string message = null) where TSessionId : notnull

Parameters

socket IListenSocket
sessionId TSessionId
registry IConnectionRegistry<TSessionId>
message string

Type Parameters

TSessionId

SendReliable<TSessionId, TPacket>(IListenSocket, TSessionId, IConnectionRegistry<TSessionId>, TPacket)

Sends a reliable packet to the connection mapped to sessionId. No-ops if the session ID is not bound.

public static void SendReliable<TSessionId, TPacket>(this IListenSocket socket, TSessionId sessionId, IConnectionRegistry<TSessionId> registry, TPacket packet) where TSessionId : notnull where TPacket : IDataPacket

Parameters

socket IListenSocket
sessionId TSessionId
registry IConnectionRegistry<TSessionId>
packet TPacket

Type Parameters

TSessionId
TPacket

SendUnreliableSequenced<TSessionId, TPacket>(IListenSocket, TSessionId, IConnectionRegistry<TSessionId>, TPacket)

Sends an unreliable-sequenced packet to the connection mapped to sessionId. No-ops if the session ID is not bound.

public static void SendUnreliableSequenced<TSessionId, TPacket>(this IListenSocket socket, TSessionId sessionId, IConnectionRegistry<TSessionId> registry, TPacket packet) where TSessionId : notnull where TPacket : IDataPacket

Parameters

socket IListenSocket
sessionId TSessionId
registry IConnectionRegistry<TSessionId>
packet TPacket

Type Parameters

TSessionId
TPacket

SendUnreliable<TSessionId, TPacket>(IListenSocket, TSessionId, IConnectionRegistry<TSessionId>, TPacket)

Sends an unreliable packet to the connection mapped to sessionId. No-ops if the session ID is not bound.

public static void SendUnreliable<TSessionId, TPacket>(this IListenSocket socket, TSessionId sessionId, IConnectionRegistry<TSessionId> registry, TPacket packet) where TSessionId : notnull where TPacket : IDataPacket

Parameters

socket IListenSocket
sessionId TSessionId
registry IConnectionRegistry<TSessionId>
packet TPacket

Type Parameters

TSessionId
TPacket

TryGet<TSessionId, TDomainEntity>(INetConnection, IConnectionRegistry<TSessionId>, Func<TSessionId, TDomainEntity>, out TDomainEntity)

Resolves a domain entity from a connection via the session registry and a domain lookup function.

public static bool TryGet<TSessionId, TDomainEntity>(this INetConnection connection, IConnectionRegistry<TSessionId> registry, Func<TSessionId, TDomainEntity> resolver, out TDomainEntity domainEntity) where TSessionId : notnull

Parameters

connection INetConnection
registry IConnectionRegistry<TSessionId>
resolver Func<TSessionId, TDomainEntity>
domainEntity TDomainEntity

Returns

bool

Type Parameters

TSessionId
TDomainEntity