Beispiel #1
0
        public static ServicePackHander GetInstance()
        {
            lock (lockthis)
            {
                if (_My == null)
                {
                    _My = new ServicePackHander();
                }
            }

            return(_My);
        }
Beispiel #2
0
        /// <summary>
        /// 启动
        /// </summary>
        public void Start()
        {
            if (IsRun)
            {
                LLOG("Service Is Start...", EventLogType.INFO);
                return;
            }

            BufferFormat.ObjFormatType = BuffFormatType.protobuf;
            ReadBytes.ObjFormatType    = BuffFormatType.protobuf;

            ServicePackHander.GetInstance().Loading();

            SessionDiy = new ConcurrentDictionary <long, ZYNetSession>();

            Service                   = new ZYSocketSuper(RConfig.ReadString("Host"), RConfig.ReadInt("ServicePort"), RConfig.ReadInt("MaxConnectCount"), 4096); //初始化
            Service.Connetions        = new ConnectionFilter(Service_Connection);                                                                                //注册连接回调
            Service.BinaryOffsetInput = new BinaryInputOffsetHandler(Service_BinaryInput);                                                                       //注册输入包输入回调
            Service.MessageInput      = new MessageInputHandler(Service_UserDisconnect);                                                                         //注册用户断开回调
            Service.IsOffsetInput     = true;

            RegService              = new ZYSocketSuper(RConfig.ReadString("Host"), RConfig.ReadInt("RegPort"), RConfig.ReadInt("MaxConnectCount"), 1024); //初始化注册端口
            RegService.Connetions   = new ConnectionFilter(RegServer_Connection);                                                                          //注册连接回调
            RegService.BinaryInput  = new BinaryInputHandler(RegServer_BinaryInput);                                                                       //注册输入包输入回调
            RegService.MessageInput = new MessageInputHandler(RegServer_UserDisconnect);                                                                   //注册用户断开回调

            Service.Start();
            RegService.Start();

            RegPort         = RConfig.ReadInt("RegPort");
            BufferMaxLength = RConfig.ReadInt("BufferLength");


            LLOG("Service StartIng...", EventLogType.INFO);



            IsRun = true;
        }