diff --git a/src/Fleck/WebSocketServer.cs b/src/Fleck/WebSocketServer.cs index d839c80b..439a25c5 100644 --- a/src/Fleck/WebSocketServer.cs +++ b/src/Fleck/WebSocketServer.cs @@ -14,14 +14,9 @@ public class WebSocketServer : IWebSocketServer private readonly string _scheme; private readonly IPAddress _locationIP; private Action _config; - - public WebSocketServer(string location) + + private void StartWebSocketListener() { - var uri = new Uri(location); - Port = uri.Port; - Location = location; - _locationIP = ParseIPAddress(uri); - _scheme = uri.Scheme; var socket = new Socket(_locationIP.AddressFamily, SocketType.Stream, ProtocolType.IP); if(!MonoHelper.IsRunningOnMono()){ #if __MonoCS__ @@ -37,6 +32,32 @@ public WebSocketServer(string location) ListenerSocket = new SocketWrapper(socket); SupportedSubProtocols = new string[0]; } + + //TODO: turn scheme into an enum and not a string + + /// + ///Start a WebSocketServer on the specified IPEndPoint with the desired scheme + /// + ///The scheme to use - "ws" or "wss". + ///The IPEndPoint to use + public WebSocketServer(string scheme, IPEndPoint location) + { + Port = location.Port; + Location = location.Address.ToString(); + _locationIP = location.Address; + _scheme = scheme; + StartWebSocketListener(); + } + + public WebSocketServer(string location) + { + var uri = new Uri(location); + Port = uri.Port; + Location = location; + _locationIP = ParseIPAddress(uri); + _scheme = uri.Scheme; + StartWebSocketListener(); + } public ISocket ListenerSocket { get; set; } public string Location { get; private set; }