public MessageDispatcher(BasicController basicController, IBasicHandler basicHandler, ICustomizeHandler customizeHandler)
 {
     this.hotDic           = new HotDictionary <string, BlobItem>();
     this.basicController  = basicController;
     this.basicHandler     = basicHandler;
     this.customizeHandler = customizeHandler;
 }
Exemple #2
0
 public void ieduNnurne(ICustomizeHandler icustomizeHandler_1, IBasicHandler ibasicHandler_1, IGroupManager igroupManager_1, IFriendsManager ifriendsManager_1, IContactsManager icontactsManager_1)
 {
     this.icustomizeHandler_0 = icustomizeHandler_1;
     this.ibasicHandler_0     = ibasicHandler_1;
     this.igroupManager_0     = igroupManager_1;
     this.ifriendsManager_0   = ifriendsManager_1;
     this.icontactsManager_0  = icontactsManager_1;
 }
Exemple #3
0
        /// <summary>
        /// 启动
        /// </summary>
        public void Start(int listenPort, ICustomizeHandler customizeHander, IBasicHandler basicHandler)
        {
            this.customizeHander = customizeHander;
            this.basicHandler    = basicHandler;
            if (string.IsNullOrEmpty(this.IPAddressBinding))
            {
                IPAddressBinding = IPHelper.GetLocalIPAddress();
            }
            this.Port = listenPort;
            IPEndPoint localEndPoint = new IPEndPoint(IPAddress.Parse(this.IPAddressBinding), this.Port);

            listenSocket = new Socket(localEndPoint.AddressFamily, SocketType.Stream, ProtocolType.Tcp);
            listenSocket.Bind(localEndPoint);
            listenSocket.Listen(this.MaxConnectionCount); //?表示能同时连接的最大数量
            StartAcceptRequset(null);                     // (第一次不采用可重用的SocketAsyncEventArgs对象来接受请求的Socket的Accept方式)
        }
        public async Task RunEngineAsync(int port, IBasicHandler basicHandler, ICustomizeHandler handler)
        {
            bossGroup   = new MultithreadEventLoopGroup(1);
            workerGroup = new MultithreadEventLoopGroup();
            MessageDispatcher                 dispatcher   = new MessageDispatcher(this.BasicController, basicHandler, handler);
            List <ChannelServerHandler>       handlers     = new List <ChannelServerHandler>();
            RingObject <ChannelServerHandler> ringHandlers = null;

            if (!useDefaultThread)//此处相比默认handler增加了工作线程,默认工作线程为cpu核心*2
            {
                for (int i = 0; i < workThreadCount; i++)
                {
                    WorkerEngine <RequestInfo> workerEngine = new WorkerEngine <RequestInfo>(3000, 1, dispatcher.Process);
                    workerEngine.Start();
                    handlers.Add(new ChannelServerHandler(this.userManager, workerEngine));
                }
                ringHandlers = new RingObject <ChannelServerHandler>(handlers);
            }
            else
            {
                var cChannelHandlers = new List <ChannelServerHandler>()
                {
                    new ChannelServerHandler(this.userManager, dispatcher)
                };
                ringHandlers = new RingObject <ChannelServerHandler>(cChannelHandlers);
            }
            var bootstrap = new ServerBootstrap();

            bootstrap
            .Group(bossGroup, workerGroup)
            .Channel <TcpServerSocketChannel>()
            //.Option(ChannelOption.SoBacklog, 100)
            //.Handler(new LoggingHandler(LogLevel.INFO))
            .ChildHandler(new ActionChannelInitializer <ISocketChannel>(channel =>
            {
                IChannelPipeline pipeline = channel.Pipeline;
                pipeline.AddLast(OFrameDecoder.NewOFrameDecoder());
                pipeline.AddLast(ringHandlers.GetNext());
            }));

            IChannel bootstrapChannel = await bootstrap.BindAsync(port);
        }
Exemple #5
0
 public void method_8(IBasicHandler ibasicHandler_0)
 {
     this.emptyBasicHandler_0 = ibasicHandler_0 ?? new EmptyBasicHandler();
 }
Exemple #6
0
    public void Initialize(int port, ICustomizeHandler customizeHandler, IBasicHandler basicHandler)
    {
        if (this.emptyAgileLogger_0 == null)
        {
            if (this.string_0 == null)
            {
                this.emptyAgileLogger_0 = new EmptyAgileLogger();
            }
            else
            {
                FileAgileLogger logger = new FileAgileLogger(this.string_0)
                {
                    MaxLength4ChangeFile = 0x100000L
                };
                this.emptyAgileLogger_0 = (EmptyAgileLogger)logger;
            }
        }
        Class16 class4 = new Class16();
        MessageForbiddenHandler class8 = new MessageForbiddenHandler();

        CJPlus.Rapid.WssOptions options = this.wssOptions_0 ?? new CJPlus.Rapid.WssOptions();
        this.object_0 = Class157.smethod_0((Enum6)0, true, options.X509Certificate2, options.SslProtocols, options.OnlyWssClient);
        BasicMessageTypeRoom room3 = new BasicMessageTypeRoom();

        room3.Initialize();
        this.int_0 = room3.Logon;
        this.int_1 = room3.HeartBeat;
        CustomizeMessageTypeRoom room4 = new CustomizeMessageTypeRoom();

        room4.Initialize();
        FileMessageTypeRoom room2 = new FileMessageTypeRoom();

        room2.Initialize();
        P2PSessionMessageTypeRoom room = new P2PSessionMessageTypeRoom();

        room.Initialize();
        FriendsMessageTypeRoom room5 = new FriendsMessageTypeRoom();

        room5.Initialize();
        GroupMessageTypeRoom room6 = new GroupMessageTypeRoom();

        room6.Initialize();
        ContactsMessageTypeRoom room7 = new ContactsMessageTypeRoom();

        room7.Initialize();
        this.class40_0 = new Class40(new IMessageTypeRoom[] { room3, room4, room2, room, room5, room6, room7 }, null);
        this.class40_0.method_2();
        this.class98_0             = new UserManager();
        this.class98_0.RelogonMode = RelogonMode.ReplaceOld;
        this.class98_0.method_2(this.int_2);
        this.class98_0.SetAgileLogger(this.emptyAgileLogger_0);
        this.class98_0.method_3((IConnection)this.object_0);
        this.class98_0.Initialize();
        this.class135_0 = new Class135(this.class98_0);
        RegularSender class5 = new RegularSender();

        class5.method_0(this.class98_0);
        class5.method_2(class8);
        class5.method_1((IAction)this.object_0);
        class5.method_3(this.emptyAgileLogger_0);
        if (basicHandler == null)
        {
            basicHandler = new EmptyBasicHandler();
        }
        Class159 class7 = new Class159();

        class7.Event_0 += new CbGeneric <string, IPEndPoint>(this.OnConnectionBound);
        class7.method_1(room3);
        class7.method_3(class4);
        class7.method_2(this.class98_0);
        class7.method_7(this.bool_2);
        class7.method_5(class5);
        class7.method_8(this.class21_0.DiagnosticsEnabled ? this.class64_0 : basicHandler);
        class7.method_9(this.class135_0);
        class7.method_10(this.igroupManager_0 != null);
        class7.method_12(this.bool_3);
        class7.method_14(this.bool_4);
        class7.method_15();
        this.class159_0 = class7;
        if (customizeHandler == null)
        {
            customizeHandler = new EmptyCustomizeHandler();
        }
        Server class2 = new Server();

        class2.SetStreamContract(class4);
        class2.SetAgileLogger(this.emptyAgileLogger_0);
        class2.SetICustomizeHandler(this.class21_0.DiagnosticsEnabled ? this.class64_0 : customizeHandler);
        class2.SetCustomizeMessageTypeRoom(room4);
        class2.method_1(class5);
        class2.SetUserManager(this.class98_0);
        class2.method_8(this.int_3);
        class2.method_11(this.class21_0.CheckResponseTTL4Query ? 10 : 0);
        class2.method_9(this.class135_0);
        class2.Event_0 += new CbGeneric <string, int, byte[], string>(this.method_6);
        class2.method_14(this.class21_0.CustomizeInfoHandleMode, this.class21_0.QueueWorkerThreadCount);
        this.class21_0.method_0((IConnection)this.object_0, this.class21_0.DiagnosticsEnabled ? this.class64_0.method_0() : null, class2.method_13());
        this.class112_0 = class2;
        Class132 class3 = new Class132();

        class3.method_1(room);
        class3.method_0(class4);
        class3.method_2(class5);
        class3.method_3(this.class98_0);
        class3.method_4(this.class135_0);
        class3.method_5(this.emptyAgileLogger_0);
        this.class2_0 = new FileTransfering();
        this.class2_0.method_0(this.emptyAgileLogger_0);
        this.class13_0 = new FileHandler();
        this.class13_0.method_0(this.emptyAgileLogger_0);
        this.class2_0.TTL4ResumedFileItem = this.class21_0.TempFile4ResumedTTL;
        this.class13_0.method_2(class5);
        this.class13_0.method_3(class4);
        this.class13_0.imethod_1(0x100000);
        this.class13_0.method_4(new Class3(0x800));
        this.class13_0.method_7(this.class21_0.UseWorkThreadPool);
        this.class13_0.Initialize("_0", room2.FilePackageData);
        this.class27_0 = new Parameterized(port);
        this.class27_0.method_2(this.class21_0.CheckFileZeroSpeedSpanInSecs);
        this.class27_0.method_0(this.emptyAgileLogger_0);
        this.class27_0.method_11(this.class13_0);
        this.class27_0.method_13(room2);
        this.class27_0.method_12(this.class2_0);
        this.class27_0.method_14(class4);
        this.class27_0.method_15(class5);
        this.class27_0.method_3("_0");
        Class69 class6 = new Class69();

        class6.method_0(room2);
        class6.method_6(class5);
        class6.method_1(class4);
        class6.method_3(this.class13_0);
        class6.method_2(this.class2_0);
        class6.method_4(this.class27_0);
        this.class98_0.SomeOneDisconnected += new CbGeneric <UserData, DisconnectedType>(this.method_8);
        this.class25_0.method_6(this.class21_0.DiagnosticsEnabled ? this.class64_0 : this.ifriendsManager_0);
        this.class25_0.method_1(room5);
        this.class25_0.method_7(this.class135_0);
        this.class25_0.method_3(class4);
        this.class25_0.method_5(class5);
        this.class25_0.method_2(this.class98_0);
        this.class25_0.method_9();
        this.class139_0.SetMessageTypeRoom(room6);
        this.class139_0.method_2(class4);
        this.class139_0.method_4(class5);
        this.class139_0.method_0(this.class98_0);
        this.class139_0.SetGroupManager(this.class21_0.DiagnosticsEnabled ? this.class64_0 : this.igroupManager_0);
        this.class139_0.method_6(this.class135_0);
        this.class139_0.Init();
        this.class60_0.method_1(room7);
        this.class60_0.method_2(class4);
        this.class60_0.method_4(class5);
        this.class60_0.method_0(this.class98_0);
        this.class60_0.method_5(this.class21_0.DiagnosticsEnabled ? this.class64_0 : this.icontactsManager_0);
        this.class60_0.method_6(this.class135_0);
        this.class60_0.method_7();
        IProcess[]        processers = new IProcess[] { class7, class2, class6, class3, this.class25_0, this.class139_0, this.class60_0 };
        MessageDispatcher class9     = new MessageDispatcher(new Class144(new Class115(processers)), class8);

        class9.imethod_0(this.emptyAgileLogger_0);
        this.object_0.imethod_22(this);
        this.object_0.SetAgileLogger(this.emptyAgileLogger_0);
        this.object_0.LjXdpkRter(this.string_1);
        this.object_0.SetData(port);
        this.object_0.imethod_10(GlobalUtil.MaxLengthOfMessage);
        this.object_0.SetStreamContract(class4);
        this.object_0.imethod_12(class9);
        this.object_0.SocketSendBuffSize = this.class21_0.SocketSendBuffSize;
        this.object_0.imethod_26((this.class21_0.WriteTimeoutInSecs <= 0) ? -1 : (this.class21_0.WriteTimeoutInSecs * 0x3e8));
        this.object_0.MaxChannelCacheSize          = this.class21_0.MaxChannelCacheSize;
        this.object_0.Boolean_0                    = this.class21_0.Boolean_0;
        this.object_0.AsynConnectionEvent          = this.class21_0.AsynConnectionEvent;
        this.object_0.UncompletedSendingCount4Busy = this.class21_0.UncompletedSendingCount4Busy;
        ((BaseTcpEngine)this.object_0).method_1(new Class119(class2, this.class98_0));
        this.object_0.Initialize();
        if (this.bool_1)
        {
            this.class17_0 = new Class17(this.class98_0, new SecurityFileLogger(this.emptyAgileLogger_0));
            this.class17_0.method_2();
        }
        if (this.bool_3)
        {
            this.object_1 = this.method_9(port + 1);
        }
        this.class64_0.ieduNnurne(customizeHandler, basicHandler, this.igroupManager_0, this.ifriendsManager_0, this.icontactsManager_0);
        this.bool_0 = true;
    }