Ejemplo n.º 1
0
 public byte[] MessageHandler(byte[] bytes)
 {
     byte[] response = null;
     try
     {
         var segment = new ArraySegment <byte>(bytes, 1, bytes.Length - 1);
         response = HandleMessage(segment, (RemoteCommandType)bytes[0]);
     }
     catch (Exception ex)
     {
         _log.WriteError(String.Format("{0} {1}", (RemoteCommandType)bytes[0], ex.Message));
     }
     return(response);
 }
Ejemplo n.º 2
0
        private void OnTimerElapsed(object sender, ElapsedEventArgs e)
        {
            Tuple <CurrencyName, IPEndPoint> pair = null;

            lock (_obj)
            {
                if (_connections.Count == 0)
                {
                    return;
                }
                pair = _connections[_counter];
            }
            try
            {
                _tcp.InvokeServer(pair.Item2, new byte[] { (byte)pair.Item1 });
            }
            catch (SocketException sx)
            {
                _log.WriteError(String.Format("[{0}] {1}", sx.SocketErrorCode.ToString(), sx.Message));
            }
            if (++_counter == _connections.Count)
            {
                _counter = 0;
            }
        }