Exemple #1
0
        private void SendInternal(IMessageTree tree)
        {
            if (_mActiveChannel != null && _mActiveChannel.Connected)
            {
                // Re-use the existing buffer.
                buf.Reset();

                _mCodec.Encode(tree, buf);

                // Nullify reference as early as possible
                tree.Message = null;

                byte[] data = buf.ToArray();

                _mActiveChannel.Client.Send(data);

                if (_mStatistics != null)
                {
                    _mStatistics.OnBytes(data.Length);
                }
            }
            else
            {
                tree.Message = null;
                Logger.Warn("SendInternal中,Socket关闭");
            }
        }
Exemple #2
0
        public override String ToString()
        {
            PlainTextMessageCodec codec = new PlainTextMessageCodec();
            ChannelBuffer         buf   = new ChannelBuffer(8192);

            codec.EncodeMessage(this, buf);
            buf.Reset();

            return(buf.ToString());
        }
Exemple #3
0
        public override string ToString()
        {
            PlainTextMessageCodec codec = new PlainTextMessageCodec();
            ChannelBuffer         buf   = new ChannelBuffer(8192);

            codec.Encode(this, buf);

            buf.Reset();
            buf.Skip(4); // get rid of length

            return(buf.ToString());
        }
Exemple #4
0
        public override String ToString()
        {
            try
            {
                PlainTextMessageCodec codec = new PlainTextMessageCodec();
                ChannelBuffer         buf   = new ChannelBuffer(8192);

                codec.EncodeMessage(this, buf);
                buf.Reset();

                return(buf.ToString());
            }
            catch (Exception ex)
            {
                Cat.lastException = ex;
                return("");
            }
        }
        public override String ToString()
        {
            try
            {
                PlainTextMessageCodec codec = new PlainTextMessageCodec();
                ChannelBuffer buf = new ChannelBuffer(8192);

                codec.Encode(this, buf);

                buf.Reset();
                buf.Skip(4); // get rid of length

                return buf.ToString();
            }
            catch (Exception ex)
            {
                Cat.lastException = ex;
                return "";
            }
        }