// Try to send a message to the Server public bool Send(Message Msg) { try { lock (Inner) // Thread safe Msg.Serialise(Out); } catch { return false; } return true; }
// Send a message to a single client public void Send(Message m) { try { lock (Connection) // Thread safe { if (Connected) m.Serialise(Out); // Serialise the message out } } catch { // If the send failed, treat it as a disconnect Disconnect(this, new DisconnectMessage(DisconnectType.Unexpected)); } }