/// <summary> /// Closes the WebSocket connection, and releases all associated resources. /// </summary> public void Close() { var msg = _readyState.CheckIfClosable(); if (msg != null) { error(msg); return; } var send = _readyState == WebSocketState.Open; close(new PayloadData(), send, send); }
/// <summary> /// Closes the WebSocket connection, and releases all associated resources. /// </summary> public Task CloseAsync() { var msg = _readyState.CheckIfClosable(); if (msg != null) { error(msg); return(Task.CompletedTask); } var send = _readyState == WebSocketState.Open; return(CloseAsync(new PayloadData(), send, send)); }