public void StartServer([NotNull] IButtplugServiceFactory aFactory, int aPort = 12345, bool aSecure = false) { CancellationTokenSource cancellation = new CancellationTokenSource(); _factory = aFactory; var endpoint = new IPEndPoint(IPAddress.Any, aPort); _server = new WebSocketListener(endpoint); var rfc6455 = new vtortola.WebSockets.Rfc6455.WebSocketFactoryRfc6455(_server); _server.Standards.RegisterStandard(rfc6455); if (aSecure) { var cert = CertUtils.GetCert("B******g"); _server.ConnectionExtensions.RegisterExtension(new WebSocketSecureConnectionExtension(cert)); } _server.Start(); Task.Run(() => AcceptWebSocketClientsAsync(_server, cancellation.Token)); }
public void StartServer([NotNull] IButtplugServerFactory aFactory, int aPort = 12345, bool aLoopBack = true, bool aSecure = false, string aHostname = "localhost") { _cancellation = new CancellationTokenSource(); _factory = aFactory; _logManager = new ButtplugLogManager(); _logger = _logManager.GetLogger(this.GetType()); var endpoint = new IPEndPoint(aLoopBack ? IPAddress.Loopback : IPAddress.Any, aPort); _server = new WebSocketListener(endpoint); var rfc6455 = new vtortola.WebSockets.Rfc6455.WebSocketFactoryRfc6455(_server); _server.Standards.RegisterStandard(rfc6455); if (aSecure) { var cert = CertUtils.GetCert("B******g", aHostname); _server.ConnectionExtensions.RegisterExtension(new WebSocketSecureConnectionExtension(cert)); } _server.Start(); Task.Run(() => AcceptWebSocketClientsAsync(_server, _cancellation.Token)); }