Esempio n. 1
0
        string localIP;                    // 本机IP地址

        public Server()
        {
            serverTaskMgr = new ServerTaskMgr(this);
            dePacketor    = new DePacketor();

            SetUseSingleSendTaskProcesser(useSingleSendTaskProcesser);
            UniqueID.GetInstance();
        }
Esempio n. 2
0
        public DePacketor CreateDePacketor()
        {
            DePacketor httpDePacketor = new DePacketor();

            httpDePacketor.SetPackHeadPreLength(0);
            httpDePacketor.SetPackTailLength(0);
            httpDePacketor.SetGetPackDataLengthCallBack(GetHttpPackDataLength);
            httpDePacketor.SetMsgProcesser(this);

            return(httpDePacketor);
        }
Esempio n. 3
0
        void Init(TaskProcesser taskProcesser)
        {
            httpMsgProcesser = new HttpMsgProcesser(this);
            httpDePacketor   = httpMsgProcesser.CreateDePacketor();

            gamepackMsgProcesser = new GamePackMsgProcesser(this);
            gamepackDePacketor   = gamepackMsgProcesser.CreateDePacketor();

            server = new Server();
            server.SetServerTaskProcess(-1, taskProcesser);
            server.SetListenPort(listenPort);
            server.SetDePacketor(httpDePacketor);
        }
Esempio n. 4
0
        public void SetDePacketor(DePacketor _dePacketor)
        {
            if (!isStop || _dePacketor == null)
            {
                return;
            }

            if (_dePacketor == dePacketor)
            {
                return;
            }

            dePacketor = _dePacketor;
        }
Esempio n. 5
0
        private int GetHttpPackDataLength(DePacketor dePacket, byte[] pack, int offset, int packLen, out int realPackHeadLen)
        {
            for (int i = offset; i < packLen - 3; i++)
            {
                if (pack[i] == '\r' &&
                    pack[i + 1] == '\n' &&
                    pack[i + 2] == '\r' &&
                    pack[i + 3] == '\n')
                {
                    realPackHeadLen = i + 4;
                    return(0);
                }
            }

            realPackHeadLen = -1;
            return(-1);
        }
Esempio n. 6
0
        public void SetSocketState(SocketState state)
        {
            socketState = state;

            if ((socketState == SocketState.CONNECTED_SERVER ||
                 socketState == SocketState.CONNECTTING_SERVER) &&
                remoteServerInfo != null &&
                remoteServerInfo.dePacketor != null)
            {
                dePacketor = remoteServerInfo.dePacketor;
            }
            else
            {
                Server server = serverTask.GetServer();
                dePacketor = server.dePacketor;
            }

            unPackHeadLen = dePacketor.GetPackHeadPreLength();
        }
Esempio n. 7
0
        public void SetDePacketor(DePacketor depacketor)
        {
            if (depacketor == dePacketor)
            {
                return;
            }

            this.dePacketor = depacketor;

            if (dePacketor != null)
            {
                unPackHeadLen = dePacketor.GetPackHeadPreLength();
            }

            RemovePack();

            unPackCache.buf = null;
            unPackCache.len = 0;
            unPackCalcLen   = 0;
            cachePack       = null;
            cachePackLen    = 0;
        }
Esempio n. 8
0
 public abstract void SetDePacketor(DePacketor dePacketor);
Esempio n. 9
0
 public override void SetDePacketor(DePacketor dePacketor)
 {
     dePacketor.SetUnPackCallBack(UnPack, this);
 }