private async void SendMessagesThread(CancellationToken token) { while (ConnectionStatus == ConnectionStatus.Connected) { while (SendMessageQueue.TryDequeue(out var message) && message != null) { try { LidgrenServer.SendMessageToClient(this, message); } catch (Exception e) { ClientException.HandleDisconnectException("Send network message error: ", this, e); return; } LmpPluginHandler.FireOnMessageSent(this, message); } try { await Task.Delay(IntervalSettings.SettingsStore.SendReceiveThreadTickMs, token); } catch (TaskCanceledException) { break; } } }
private async void SendMessagesThread() { while (ConnectionStatus == ConnectionStatus.Connected) { if (SendMessageQueue.TryDequeue(out var message) && message != null) { try { ServerContext.LidgrenServer.SendMessageToClient(this, message); } catch (Exception e) { ClientException.HandleDisconnectException("Send network message error: ", this, e); return; } LmpPluginHandler.FireOnMessageSent(this, message); }