Example #1
0
        protected override void Decode(IChannelHandlerContext context, IByteBuffer input, List <object> output)
        {
            var header = LoraParser.HeaderParse(input);

            Console.WriteLine($"消息头解析结果:fun = {header.FunType}, mac = {header.SrcMac}, content = {BytesUtil.BytesToHexWithSeparator(header.Content,"-")}");
            output.Add(header);
        }
        protected override void Decode(IChannelHandlerContext context, IByteBuffer input, List <object> output)
        {
//            var msg = new byte[input.ReadableBytes];
//            input.ReadBytes(msg);
            var msg    = LoraParser.Split(input);
            var hex    = BytesUtil.HexInsertSpace(BytesUtil.BytesToHex(msg));
            var srcMac = hex.Substring(50, 18).Replace(" ", "");

            Console.WriteLine($"Time: {DateTime.Now} Mac: {srcMac} => 收到服务器消息:{hex}");
            output.Add(Unpooled.WrappedBuffer(msg));
        }