Пример #1
0
        private void BuildMessage(object state)
        {
            byte[] datagram;
            try
            {
                UdpWriter uw = new UdpWriter();
                _sendingTicket.BuildRpcMessage(uw);
                datagram = uw.Build();
            }
            catch (Exception ex)
            {
                Log.Debug("UDP datagram not builded (xid:{0}) reason: {1}", _sendingTicket.Xid, ex);
                lock (_sync)
                    _handlers.Remove(_sendingTicket.Xid);
                _sendingTicket.Except(ex);
                OnSend();
                return;
            }


            Log.Debug("Begin sending UDP datagram (xid:{0})", _sendingTicket.Xid);
            _client.AsyncWrite(datagram, OnDatagramWrited);
        }
Пример #2
0
        private void BuildMessage(object state)
        {
            LinkedList <byte[]> blocks;

            try
            {
                TcpWriter tw = new TcpWriter(_maxBlock);
                _sendingTicket.BuildRpcMessage(tw);
                blocks = tw.Build();
            }
            catch (Exception ex)
            {
                Log.Debug("TCP message not builded (xid:{0}) reason: {1}", _sendingTicket.Xid, ex);
                lock (_sync)
                    _handlers.Remove(_sendingTicket.Xid);
                _sendingTicket.Except(ex);
                OnSend();
                return;
            }

            BeginReceive();
            Log.Debug("Begin sending TCP message (xid:{0})", _sendingTicket.Xid);
            _client.AsyncWrite(blocks, OnBlocksWrited);
        }