Пример #1
0
        /// <summary>
        /// 连接服务器
        /// </summary>
        /// <param name="ip"></param>
        /// <param name="tcpPort"></param>
        /// <param name="udpPort"></param>
        public void Connect(string ip, int tcpPort, int udpPort, Mode initMode, Protocol initProtocol)
        {
            if (IsConnected)
            {
                return;
            }

            MessageBuffer.MESSAGE_MAX_VALUE = 1000;
            MessageBuffer.MESSAGE_MIN_VALUE = 0;

            mode     = initMode;
            protocol = initProtocol;

            mTcp = new TcpService();

            mIP      = ip;
            mTCPPort = tcpPort;
            mUDPPort = udpPort;

            mTcp.OnConnect    += OnTcpConnect;
            mTcp.OnDisconnect += OnTcpDisconnect;
            mTcp.OnMessage    += OnReceive;

            mTcp.Connect(mIP, mTCPPort);
        }
Пример #2
0
        public void Connect(string ip, int tcpPort)
        {
            if (IsConnected)
            {
                return;
            }

            mTcp = new TcpService(this);

            mIP      = ip;
            mTCPPort = tcpPort;
            //mUDPPort = 0;


            //if (mUDPPort == 0)
            //{
            //    mTcp.onConnect += OnConnect;
            //}

            mTcp.onConnect    += OnConnect;
            mTcp.onDisconnect += OnDisconnect;
            mTcp.onException  += onException;
            mTcp.onMessage    += OnReceive;

            mTcp.Connect(mIP, mTCPPort);
        }
Пример #3
0
 public NetworkService(int tcp, int udp, bool kcp)
 {
     mTcp = new TcpService(this, tcp);
     if (kcp)
     {
         mKcp = new KcpService(this, udp);
     }
     else
     {
         mUdp = new UdpService(this, udp);
     }
 }
 public NetworkService(int tcp, int udp, bool kcp)
 {
     mTcp = new TcpService(this, tcp);
 }
 public NetworkService(int tcp)
 {
     mTcp = new TcpService(this, tcp);
 }