public void Send(Protocol protocol) { try { byte[] sendBytes = protocol.ToByteArray(); this.stream.Write(sendBytes, 0, sendBytes.Length); } catch { this.FireOnConnectionLost(); } }
public void Send(Protocol protocol) { lock (locker) { try { byte[] sendBytes = protocol.ToByteArray(); if (stream.CanWrite == true) { this.stream.Write(sendBytes, 0, sendBytes.Length); } } catch { this.FireOnConnectionLost(); } } }