Table of Contents

Interface IClientAdapter

Namespace
BSGameLib.Networking
Assembly
BSGameLib.Networking.dll

The client side of the network, as a game sees it.

public interface IClientAdapter : INetworkAdapter
Inherited Members

Properties

HandlerRunner

What each received packet's handler is run through, or null to run it where it arrives.

Action<Type, Action> HandlerRunner { get; set; }

Property Value

Action<Type, Action>

Remarks

Packets arrive on the transport's receive threads: reliable ones one at a time, in order, on one thread, and unreliable ones on another, beside whatever thread runs the game's own loop. A game that wants handlers on its loop's thread sets this to something that queues them there; one that wants them one at a time with its own work sets it to something that takes its lock, runs the handler and lets go. It is given the packet's type, or null for one this side does not know, so that it can say which packet it is running: for timing them, say.

IsConnected

Whether there is a connection to the server.

bool IsConnected { get; }

Property Value

bool

Methods

Connect(string, int)

Connects to the server at ipAddress and port, blocking until the connection is made or fails.

void Connect(string ipAddress, int port)

Parameters

ipAddress string
port int

Disconnect(string)

Closes the connection, if there is one, and raises Disconnected. A reason given is passed on in the event's DisconnectReason; the server is not told it.

void Disconnect(string reason = "")

Parameters

reason string

GetStatistics()

Traffic since this client started, and the connection to the server with its round-trip time, while there is one.

NetworkStatistics GetStatistics()

Returns

NetworkStatistics

SendReliable<T>(T)

Sends packet to the server reliably and in order.

void SendReliable<T>(T packet) where T : IDataPacket

Parameters

packet T

Type Parameters

T

SendUnreliableSequenced<T>(T)

Sends packet to the server without delivery guarantees. A packet that arrives after a newer one is dropped.

void SendUnreliableSequenced<T>(T packet) where T : IDataPacket

Parameters

packet T

Type Parameters

T

SendUnreliable<T>(T)

Sends packet to the server without delivery or order guarantees.

void SendUnreliable<T>(T packet) where T : IDataPacket

Parameters

packet T

Type Parameters

T

Events

Connected

Raised when the connection to the server is made.

event EventHandler<ClientEventArgs> Connected

Event Type

EventHandler<ClientEventArgs>

Disconnected

Raised when the connection to the server closes.

event EventHandler<ClientEventArgs> Disconnected

Event Type

EventHandler<ClientEventArgs>