ISocket
An interface in Root.Township, Alta.Networking.
The game's network socket: owns the list of Connections and sends messages over the transport. The live one is Socket.Current (a FakeSocket when offline); on a server it holds one connection per player.
- Listed in Networking and servers
- Inherits or implements
IDisposable - Derived types
FakeSocket,Socket
Properties
| Member | What it is |
|---|---|
int ConnectionCount { get; } | Number of open connections. |
IEnumerable<Connection> Connections { get; } | All open connections. |
ConnectionChannel DefaultChannel { get; set; } | Channel given to new connections as their default. |
bool IsServer { get; } | True when this socket was opened as a server. |
int OutgoingQueueSize { get; set; } | Size of the transport's outgoing queue, updated each send. |
ITransportSocket TransportSocket { get; } | The low level transport socket underneath. |
Events
| Member | What it is |
|---|---|
event ConnectionEventHandler ConnectionCreated | Raised when a connection is added. |
event ConnectionEventHandler ConnectionDestroyed | Raised after a connection is removed and disposed. |
event Action<ISocket> SocketDestroyed | Raised when the socket is shut down. |
Methods
| Member | What it is |
|---|---|
Connection CreateConnection(ITransportConnection transportConnection, string ipAddress) | Adds a connection, either wrapping an incoming transport connection or connecting out to an address and port (localhost means 127.0.0.1). |
Connection CreateConnection(string ipAddress, int port) | Adds a connection, either wrapping an incoming transport connection or connecting out to an address and port (localhost means 127.0.0.1). |
void DestroyConnection(Connection connection, bool isFlushing = false) | Removes and disposes a connection, optionally sending its queued packets first, then raises ConnectionDestroyed. |
Connection GetConnection(int identifier) | Finds a connection by its transport id, or null. |
bool SendToAll(ConnectionChannel channel, MessageType type, SerializeConnectionMethod handler) | Serialises a message once and sends it to every connection. Returns false if any send failed. |
bool SendToPlayers(ConnectionChannel channel, MessageType type, SerializeConnectionMethod handler, IEnumerable<IPlayer> players) | Serialises a message once (using the first player's connection) and sends it to each listed player. |
void UpdateReceive() | Processes each connection's queued messages, then reads new packets from the transport. |
void UpdateSend() | Flushes each connection's outgoing packet managers (rotating who goes first) and sends them. |
Used in
Members of other types that take, return or hold a ISocket:
ClientPacketReceiver.ClientPacketReceiver, ClientPacketReceiver.Socket, Connection.Connection, Connection.Socket, FakeSocket.SocketDestroyed, INetworkSceneInternal.Initialize, SceneSerializer.SendSerialized, NetworkManager.CloseSocket, NetworkManager.CreateSocket, NetworkManager.sockets, NetworkScene.clientSocket, NetworkScene.Initialize, NetworkScene.SendSerialized, NetworkScene.serverSocket, ServerMessageReceiverPerConnection.ServerMessageReceiverPerConnection, ServerMessageReceiverPerConnection.socket, ServerPacketReceiver.ServerPacketReceiver, ServerPacketReceiver.Socket, ConnectToServerUtility.CleanStaticSocket, ConnectToServerUtility.socket, ServerHandler.ServerHandler, ServerHandler.socket, ServerLifetimePipeline.ServerEnded, Socket.Current, Socket.SocketDestroyed, SocketEventHandler.BeginInvoke, SocketEventHandler.Invoke, JoinServerGameModeBase.DisconnectedFromServer, JoinServerPipeline.JoinServerPipeline, JoinServerPipeline.socket, LocalNetworkScene.Initialize, LocalNetworkScene.SendSerialized.