Exemplo n.º 1
0
        public Task <bool> DisconnectAsync(uint data = 0)
        {
            NativeMethods.EnetPeerDisconnect(this.peerPtr, data);
            // EnetPeerDisconnect会reset Peer,这里设置为0,防止再次Dispose
            this.PeerPtr = IntPtr.Zero;
            var tcs = new TaskCompletionSource <bool>();

            this.Disconnect = eEvent => tcs.TrySetResult(true);
            return(tcs.Task);
        }