Ejemplo n.º 1
0
        public static async Task CloseSocketAndThrow(ArraySegment <byte> buffer, ClientWebSocket socket, WebSocketCloseStatus status, string description, CancellationToken cancellation)
        {
            var array = buffer.Array;

            if (array.Length != WebsocketHelper.ORIGINAL_BUFFER_SIZE)
            {
                Array.Resize(ref array, WebsocketHelper.ORIGINAL_BUFFER_SIZE);
            }
            await WebsocketHelper.CloseSocket(socket, status, description, cancellation);

            throw new WebSocketException($"The socket has been closed ({status}: {description})");
        }
 public async Task DisposeAsync()
 {
     _cts.Cancel();
     await WebsocketHelper.CloseSocket(socket);
 }
 public async void Dispose()
 {
     _cts.Cancel();
     await WebsocketHelper.CloseSocket(socket);
 }