/// <summary> /// Start the server /// </summary> public void Start() { WebSocketServer.RunAsync(); var address = WebSocketServer.ServerFeatures.Get <IServerAddressesFeature>().Addresses.FirstOrDefault(); BotServices.GetService <IBotLogger>().LogInformation($"Websocket server started on {address}"); }
/// <summary> /// Stop the server /// </summary> public async Task Stop() { BotServices.GetService <IBotLogger>().LogInformation($"Websocket server stopping all clients..."); WebSocketClients.ForEach(async delegate(WebSocketClient client) { await client.CloseAsync(); }); await WebSocketServer.StopAsync(); BotServices.GetService <IBotLogger>().LogInformation($"Websocket server stopped"); }