示例#1
0
        public void OnAccept(int sock, int protocol)
        {
            mAcceptSock = sock;

            if (protocol == 0)
            {
                mUdp              = new UdpService(this);
                mUdp.onConnect   += OnConnect;
                mUdp.onDisconnet += OnDisconnect;
                mUdp.onException += onException;
                mUdp.onMessage   += OnReceive;

                mUdp.Connect(mIP, mUDPPort);
            }
            else
            {
                mKcp              = new KcpService(this, (uint)mAcceptSock);
                mKcp.onConnect   += OnConnect;
                mKcp.onDisconnet += OnDisconnect;
                mKcp.onException += onException;
                mKcp.onMessage   += OnReceive;

                mKcp.Connect(mIP, mUDPPort);
            }
        }
示例#2
0
        /// <summary>
        /// 选择性连接UDP服务器或者KCP服务器
        /// </summary>
        /// <param name="sock"></param>
        /// <param name="protocol"></param>
        public void OnAccept(int sock, Protocol protocol)
        {
            mAcceptSock = sock;

            if (protocol == Protocol.UDP)
            {
                mUdp = new UdpService();
                mUdp.Connect(mIP, mUDPPort);
            }
            else
            {
                mKcp = new KcpService((uint)mAcceptSock);
                mKcp.Connect(mIP, mUDPPort);
            }
        }