示例#1
0
        public void sendMessage(Message <T> message)
        {
            var lenth      = _protoDecodeEncode.CalculationLenth(message);
            var bytebuffer = PooledByteBufferAllocator.Default.DirectBuffer(lenth);

            _protoDecodeEncode.encode(bytebuffer, message);

            // if (protocolType == Ukcp.TCP_PROTOCOL)
            // {
            //     _tcpChannel.WriteAndFlushAsync(bytebuffer);
            // }
            //TODO 缓冲区满了?
            try
            {
                // if (protocolType == Ukcp.UDP_PROTOCOL)
                // {
                //     _kcpChannel.writeUdpMessage(bytebuffer);
                // }
                // else if(protocolType== Ukcp.KCP_PROTOCOL)
                // {
                //     _kcpChannel.writeMessage(bytebuffer);
                // }
            }
            finally
            {
                bytebuffer.Release();
            }
        }
示例#2
0
 protected override void Encode(IChannelHandlerContext context, Message <T> message, IByteBuffer output)
 {
     _protoDecodeEncode.encode(output, message);
 }