Beispiel #1
0
        /// <summary>
        /// Sending thread loop.
        /// </summary>
        private void SendingMethod()
        {
            while (IsConnected)
            {
                if (_commandQueue.Count > 0)
                {
                    WatchoutCommand command = null;

                    if (_commandQueue.TryDequeue(out command))
                    {
                        String commandText = CommandFormatter.Serialize(command);
                        Debug.WriteLine("Sending: " + commandText);

                        try
                        {
                            var    stream       = _tcpClient.GetStream();
                            byte[] commandBytes = Encoding.UTF8.GetBytes(commandText);
                            stream.Write(commandBytes, 0, commandBytes.Length);
                        }
                        catch { }
                    }
                }

                Thread.Sleep(30);
            }
        }
 /// <summary>
 /// Serializes this command.
 /// </summary>
 /// <returns>A string representation of this command.</returns>
 public String Serialize()
 {
     return(CommandFormatter.Serialize(this));
 }