예제 #1
0
        public static MessageHandler Create(Type handlerType, NetChannel channel)
        {
            var handler = (MessageHandler)PopoObjectPool.Fetch(handlerType, channel);

            handler.Channel = channel;
            return(handler);
        }
예제 #2
0
        public static T Create <T>(NetChannel channel) where T : MessageHandler
        {
            var type    = typeof(T);
            var handler = (T)PopoObjectPool.Fetch(typeof(T), channel);

            return(handler);
        }
예제 #3
0
 private void CreateMessageHandlers(NetChannel channel)
 {
     foreach (var type in handlerTypes)
     {
         MessageHandlerFactory.Create(type, channel);
     }
 }
예제 #4
0
 private async void OnChannelError(NetChannel channel, SocketError socketError)
 {
     if (channel.ChannelType == ChannelType.Client)
     {
         if (!await channel.ReConnecting())
         {
             channel.Close();
         }
         else
         {
             return;
         }
     }
     else
     {
         channel.DisConnect();
     }
     Channels.TryRemove(channel.ObjectId, out NetChannel valu);
 }
예제 #5
0
 public MessageHandler(NetChannel channel, int handlerId)
 {
     this.Channel          = channel;
     this.Channel.OnClose += () => { this.Close(); };
 }
예제 #6
0
 public MessageDistribute(NetChannel channel, int handlerId) : base(channel, handlerId)
 {
 }