public void Enqueue(InputBase input) { _inputQueue.Enqueue(input); }
private void Send(InputBase input) { try { if (ClientSocket == null || !ClientSocket.Connected) { // not connected throw new SocketException(); } byte[] buf = null; var stream = new System.IO.MemoryStream(); using (var writer = new System.IO.BinaryWriter(stream)) { stream.Seek(3, System.IO.SeekOrigin.Begin); Serializer.WriteObject(stream, input); var len = (ushort)(stream.Position - 3); stream.Seek(0, System.IO.SeekOrigin.Begin); stream.WriteByte(0x1b); writer.Write(len); buf = stream.ToArray(); } SocketError socketError; ClientSocket.BeginSend(buf, 0, buf.Length, SocketFlags.None, out socketError, BeginSendCallback, ClientSocket); } catch { this.Detach(); throw; } }