Ejemplo n.º 1
0
        internal void DisconnectPeer(
            NetPeer peer,
            DisconnectReason reason,
            int socketErrorCode,
            bool force,
            byte[] data,
            int start,
            int count)
        {
            if (peer == null)
            {
                return;
            }
            lock (_peers)
            {
                if (!_peers.ContainsAddress(peer.EndPoint) || !peer.Shutdown(data, start, count, force))
                {
                    //invalid peer
                    return;
                }
            }
            var netEvent = CreateEvent(NetEventType.Disconnect);

            netEvent.Peer             = peer;
            netEvent.AdditionalData   = socketErrorCode;
            netEvent.DisconnectReason = reason;
            EnqueueEvent(netEvent);
        }
Ejemplo n.º 2
0
        internal void DisconnectPeer(
            NetPeer peer,
            DisconnectReason reason,
            int socketErrorCode,
            bool force,
            byte[] data,
            int start,
            int count)
        {
            if (!peer.Shutdown(data, start, count, force))
            {
                //already shutdowned. no need send event
                return;
            }
            var netEvent = CreateEvent(NetEventType.Disconnect);

            netEvent.Peer             = peer;
            netEvent.AdditionalData   = socketErrorCode;
            netEvent.DisconnectReason = reason;
            EnqueueEvent(netEvent);
        }