From 86921077de296282796ac90dfe7516cccb4ce699 Mon Sep 17 00:00:00 2001 From: sta Date: Thu, 24 Dec 2020 22:46:42 +0900 Subject: [PATCH] [Modify] Add it --- websocket-sharp/Net/HttpListenerContext.cs | 24 ++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/websocket-sharp/Net/HttpListenerContext.cs b/websocket-sharp/Net/HttpListenerContext.cs index eac93fb5..643465cc 100644 --- a/websocket-sharp/Net/HttpListenerContext.cs +++ b/websocket-sharp/Net/HttpListenerContext.cs @@ -240,6 +240,30 @@ namespace WebSocketSharp.Net return true; } + internal HttpListenerWebSocketContext GetWebSocketContext (string protocol) + { + if (_websocketContext != null) + return _websocketContext; + + if (protocol != null) { + if (protocol.Length == 0) { + var msg = "An empty string."; + + throw new ArgumentException (msg, "protocol"); + } + + if (!protocol.IsToken ()) { + var msg = "It contains an invalid character."; + + throw new ArgumentException (msg, "protocol"); + } + } + + _websocketContext = new HttpListenerWebSocketContext (this, protocol); + + return _websocketContext; + } + internal bool Register () { return _listener.RegisterContext (this);