private void SendTo(ClientManager receiver, IrssMessage message) { IrssLog.Debug("SendTo({0}, {1})", message.Type, message.Flags); if (!_server.Send(receiver, message)) { IrssLog.Warn("Failed to send message to a client, unregistering client"); // If a message doesn't get through then unregister that client UnregisterClient(receiver); } }
/// <summary> /// Create a new MessageManagerCombo structure instance. /// </summary> /// <param name="message">The IrssMessage to encapsulate.</param> /// <param name="manager">The ClientManager to encapsulate.</param> public MessageManagerCombo(IrssMessage message, ClientManager manager) { _message = message; _manager = manager; }
private void SendToAllExcept(ClientManager exceptClient, IrssMessage message) { IrssLog.Debug("SendToAllExcept({0}, {1})", message.Type, message.Flags); List<ClientManager> unregister = new List<ClientManager>(); lock (_registeredClients) { foreach (ClientManager client in _registeredClients) { if (client == exceptClient) continue; if (!_server.Send(client, message)) { IrssLog.Warn("Failed to send message to a client, unregistering client"); // If a message doesn't get through then unregister that client unregister.Add(client); } } // Unregistering clients must be done as a two part process because otherwise the // foreach statement above would fail if you modified the _registeredClients list // while enumerating it. foreach (ClientManager client in unregister) { UnregisterClient(client); } } }
private bool UnregisterRepeater(ClientManager removeRepeater) { if (_registeredRepeaters == null) return false; lock (_registeredRepeaters) { if (!_registeredRepeaters.Contains(removeRepeater)) return false; _registeredRepeaters.Remove(removeRepeater); } IrssLog.Info("Unregistered a repeater"); return true; }
private bool RegisterRepeater(ClientManager addRepeater) { if (_registeredRepeaters == null) return false; lock (_registeredRepeaters) { if (!_registeredRepeaters.Contains(addRepeater)) _registeredRepeaters.Add(addRepeater); } IrssLog.Info("Registered a repeater"); return true; }
private bool UnregisterClient(ClientManager removeClient) { if (_registeredClients == null) return false; lock (_registeredClients) { if (!_registeredClients.Contains(removeClient)) return false; _registeredClients.Remove(removeClient); } IrssLog.Info("Unregistered a client"); return true; }
private bool RegisterClient(ClientManager addClient) { if (_registeredClients == null) return false; lock (_registeredClients) { if (!_registeredClients.Contains(addClient)) _registeredClients.Add(addClient); } IrssLog.Info("Registered a client"); return true; }