Esempio n. 1
0
        private WebSocketCloseStatus MapCloseStatus(Net.CloseStatusCode code)
        {
            switch (code)
            {
            case Net.CloseStatusCode.Normal:
                return(WebSocketCloseStatus.NormalClosure);

            case Net.CloseStatusCode.ProtocolError:
                return(WebSocketCloseStatus.ProtocolError);

            case Net.CloseStatusCode.InvalidData:
            case Net.CloseStatusCode.UnsupportedData:
                return(WebSocketCloseStatus.InvalidPayloadData);

            case Net.CloseStatusCode.PolicyViolation:
                return(WebSocketCloseStatus.PolicyViolation);

            case Net.CloseStatusCode.TooBig:
                return(WebSocketCloseStatus.MessageTooBig);

            case Net.CloseStatusCode.MandatoryExtension:
                return(WebSocketCloseStatus.MandatoryExtension);

            case Net.CloseStatusCode.ServerError:
                return(WebSocketCloseStatus.InternalServerError);

            default:
                throw new ArgumentOutOfRangeException(nameof(code), code, null);
            }
        }
Esempio n. 2
0
 /// <inheritdoc />
 public Task CloseAsync(Net.CloseStatusCode code, string comment = null, CancellationToken cancellationToken = default) =>
 SystemWebSocket.CloseAsync(MapCloseStatus(code), comment ?? string.Empty, cancellationToken);