public void Send(int contextId, int module, int command, object packet) { if (_contextMap.TryGetValue(contextId, out var serverConnectorContext)) { byte[] output = ConnectorsUtils.SerializePacket(module, command, packet); TcpSocketsUtils.Send(serverConnectorContext.Socket, output, serverConnectorContext.OnSend, serverConnectorContext.OnExcp); } }
public void Send(int module, int command, object packet) { if (IsConnected == false) { throw new InvalidOperationException("Connector not connected"); } byte[] output = ConnectorsUtils.SerializePacket(module, command, packet); TcpSocketsUtils.Send(_socket, output, OnSend, OnExcp); }
public void Send(Func <ServerConnectorContext, bool> filter, int module, int command, object packet) { byte[] output = ConnectorsUtils.SerializePacket(module, command, packet); foreach (var connector in _contextMap.Values) { if (filter(connector)) { TcpSocketsUtils.Send(connector.Socket, output, connector.OnSend, connector.OnExcp); } } }