Пример #1
0
        /// <summary>
        /// initialize pomelo client
        /// </summary>
        /// <param name="host">server name or server ip (www.xxx.com/127.0.0.1/::1/localhost etc.)</param>
        /// <param name="port">server port</param>
        /// <param name="callback">socket successfully connected callback(in network thread)</param>
        public void initClient(string host, int port, Action callback = null)
        {
            eventManager = new EventManager();
            NetWorkChanged(NetWorkState.CONNECTING);

            IPEndPoint ie = new IPEndPoint(IPAddress.Parse(host), port);

            socket = new UdpClient(host, port);
            socket.Connect(ie);

            this.protocol = new KcpProtocol(this, this.socket, ie);
            NetWorkChanged(NetWorkState.CONNECTED);

            if (callback != null)
            {
                callback();
            }
        }
Пример #2
0
 public KcpHeartBeatService(int interval, KcpProtocol protocol)
 {
     this.interval = interval * 1000;
     this.protocol = protocol;
 }
Пример #3
0
 public KcpHandShakeService(KcpProtocol protocol)
 {
     this.protocol = protocol;
 }