Exemplo n.º 1
0
        public void SendFrame(ILink path, IFrame frame)
        {
            try
            {
                if (frame.Size < 1)
                {
                    return;
                }

                _reactor.LogBandwidthUsed(0, frame.Size);

                SentBytes.Inc((ulong)frame.Size);
                _reactor.SendTo(frame.Payload, frame.Size, (IPEndPoint)path.EndPoint);
            }
            catch
            {
            }
        }
Exemplo n.º 2
0
        public IAsyncResult BeginDispatch(TimeSpan timeout, IMessage msg, object state, AsyncCallback callback)
        {
            var r = new GenericAsyncResult(state)
            {
                Callback         = callback,
                UniqueIdentifier = msg.UniqueIdentifier
            };

            _syncro.WaitOne();
            _activeMessages.Add(msg.UniqueIdentifier, r);
            _syncro.Set();

            SentMessages.Inc(1);
            var obuff = GZip.SerializeAndCompress(msg);

            SentBytes.Inc((ulong)obuff.GetLength(0));
            _outChannel.Send(obuff);
            return(r);
        }
Exemplo n.º 3
0
 private bool InChannelMessageReceived(byte[] data)
 {
     try
     {
         ReceivedMessages.Inc(1);
         ReceivedBytes.Inc((ulong)data.GetLength(0));
         var message = (OpaqueMessage.OpaqueMessage)GZip.DecompressAndDeserialize(data);
         if (message == null)
         {
             return(false);
         }
         _dispatcher.Dispatch(message);
         var outbuff = GZip.SerializeAndCompress(new OpaqueMessageReply(message));
         _outChannel.Send(outbuff);
         SentBytes.Inc((ulong)outbuff.GetLength(0));
         return(true);
     }
     catch (Exception e)
     {
         STrace.Exception(GetType().FullName, e);
     }
     return(false);
 }