Ejemplo n.º 1
0
        private KCPStateObject InitKCPObject(EndPoint remote)
        {
            lock (lockObject)
            {
                KCPStateObject kcp       = null;
                string         remoteKey = RemotePoint2Key(remote);
                if (map_remote2KCP.TryGetValue(remoteKey, out kcp))
                {
                    return(kcp);
                }

                NetDebug.Log("[S] InitKCPObject, remote:{0}", remote);

                kcp = new KCPStateObject();
                kcp.Initialize(remote, setting.kcp);
                kcp.remote = remote;

                kcp.sendHandle      = OnKCPSend;
                kcp.receiveHandle   = OnKCPReceive;
                kcp.timeoutCallback = OnTimeoutCallback;
                map_remote2KCP.Add(remoteKey, kcp);

                return(kcp);
            }
        }
Ejemplo n.º 2
0
 private void OnTimeoutCallback(KCPStateObject kcpObject)
 {
     NetDebug.Log("[OnTimeoutCallback] {0}", kcpObject.remote);
     if (null != kcpObject)
     {
         Close(kcpObject.remote);
     }
 }
Ejemplo n.º 3
0
        private void InitKCP(UDPSetting setting)
        {
            _kcpObject = new KCPStateObject();
            _kcpObject.Initialize(this, setting.kcp);
            _kcpObject.remote = remoterPoint;

            _kcpObject.sendHandle    = OnKCPSend;
            _kcpObject.receiveHandle = OnKCPReceive;
        }
Ejemplo n.º 4
0
        public void Receive(EndPoint remote, byte[] data, int offset, int count)
        {
            KCPStateObject kcp = InitKCPObject(remote);

            kcp.Receive(data, offset, count);
        }