12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061 |
- using DotNetty.Transport.Channels;
- using System;
- using System.Collections.Concurrent;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- using System.Windows.Forms;
- namespace NettyClient
- {
- public class SimpleMessageHandler : ChannelHandlerAdapter
- {
- public SimpleMessageHandler() {
- }
- public IChannelHandlerContext context;
- public override void ChannelActive(IChannelHandlerContext context)
- {
- MessageBox.Show("connected");
- this.context = context;
- }
- public override void ChannelRead(IChannelHandlerContext context, object message)
- {
-
- }
- public override void ChannelReadComplete(IChannelHandlerContext context)
- {
- context.Flush();
- }
- public override void ExceptionCaught(IChannelHandlerContext context, Exception exception)
- {
- Console.WriteLine("Exception: " + exception);
- context.CloseAsync();
- }
- //public override void ChannelInactive(IChannelHandlerContext context)
- //{
- // base.ChannelInactive(context);
- // Console.WriteLine("1");
- //}
- //public override void ChannelUnregistered(IChannelHandlerContext context)
- //{
- // base.ChannelUnregistered(context);
- // Console.WriteLine("2");
- //}
- public override void HandlerRemoved(IChannelHandlerContext context)
- {
- base.HandlerRemoved(context);
- }
- //public void toString(Message msg)
- //{
- // MessageBox.Show("Received from server: cmd : " + msg.Cmd + ", taskId : " + msg.TaskId + ", content : " + msg.Content);
- //}
- }
- }
|