protected override async Task Inner_Disconnect() { if (Socket.State != WebSocketState.Open) { return; } await Socket.CloseAsync(WebSocketCloseStatus.NormalClosure, "", CancellationToken.None); }
public async void CloseWebSocket(string closeReason = null) { try { Task taskClose = cws.CloseAsync(WebSocketCloseStatus.NormalClosure, closeReason, _cancellation.Token); await taskClose; } catch (Exception excC) { await UpdateMessageArea($"CloseWebSocket Exception: {cws.CloseStatus} - {cws.CloseStatusDescription} / {excC.Message}", true); } finally { await UpdateMessageArea($"CloseWebSocket: {cws.CloseStatus} - {cws.CloseStatusDescription}", true); } }