示例#1
0
        public BaseServer()
        {
            isConnect = false;

            tcpReciver = new PackageReciver(this);
            udpReciver = new PackageReciver(this);

            tcpSocket.onCloseSocket += new TcpSocketCloseSocketDelegate(TcpOnCloseSocket);
            tcpSocket.onConnect     += new TcpSocketConnectDelegate(TcpOnConnect);
            tcpSocket.onError       += new TcpSocketErrorDelegate(TcpOnError);
            tcpSocket.onListen      += new TcpSocketListenDelegate(TcpOnListen);
            tcpSocket.onReceive     += new TcpSocketReceiveDelegate(TcpOnReceive);
            tcpSocket.onSend        += new TcpSocketSendDelegate(TcpOnSend);

            udpSocket.onBind    += new UdpSocketBindDelegate(UdpOnBind);
            udpSocket.onError   += new UdpSocketErrorDelegate(UdpOnError);
            udpSocket.onListen  += new UdpSocketListenDelegate(UdpOnListen);
            udpSocket.onReceive += new UdpSocketReceiveDelegate(UdpOnReceive);

            currentChannel = new List <int>();

            tcpReciverTask =
                CoroutineTaskManager.Instance.LoopTodoByWhile(tcpReciver.HandlePackageInQueue, Time.deltaTime, () => { return(isConnect); });
            udpReciverTask =
                CoroutineTaskManager.Instance.LoopTodoByWhile(udpReciver.HandlePackageInQueue, Time.deltaTime, () => { return(isConnect); });

            EventDispatcher.AddEventListener <string>(ServerEvent.GetChannelId, GetChannelId, this);
        }
示例#2
0
        public BaseServer()
        {
            isConnect = false;

            tcpReciver = new PackageReciver(this);
            udpReciver = new PackageReciver(this);

            tcpSocket.onCloseSocket += new TcpSocketCloseSocketDelegate(TcpOnCloseSocket);
            tcpSocket.onConnect     += new TcpSocketConnectDelegate(TcpOnConnect);
            tcpSocket.onError       += new TcpSocketErrorDelegate(TcpOnError);
            tcpSocket.onListen      += new TcpSocketListenDelegate(TcpOnListen);
            tcpSocket.onReceive     += new TcpSocketReceiveDelegate(TcpOnReceive);
            tcpSocket.onSend        += new TcpSocketSendDelegate(TcpOnSend);

            udpSocket.onBind    += new UdpSocketBindDelegate(UdpOnBind);
            udpSocket.onError   += new UdpSocketErrorDelegate(UdpOnError);
            udpSocket.onListen  += new UdpSocketListenDelegate(UdpOnListen);
            udpSocket.onReceive += new UdpSocketReceiveDelegate(UdpOnReceive);

            currentChannel = new List <int>();



            EventDispatcher.AddEventListener <string>(ServerEvent.GetChannelId, GetChannelId, this);
        }