public void NotifyClients(uint sessionId, ServerInfoBase info) { var serverName = ""; if (info is WorldServerInfo) { serverName = "WorldServer"; } else if (info is WorldNodeInfo) { serverName = "NodeServer"; } if (info == null) { if (Servers.TryRemove(sessionId, out info)) { Log.Message($"{serverName} (Realm: {info.RealmId}, Host: {info.IPAddress}, Port: {info.Port}) disconnected."); } } else { var status = "connected"; if (Servers.ContainsKey(sessionId)) { status = "updated"; } Servers.AddOrUpdate(sessionId, info, (k, v) => info); Log.Message($"{serverName} (Host: {info.IPAddress}, Port: {info.Port}, Connections: {info.ActiveConnections}) {status}."); } }
public void SendCommandToServer(CommandData data, long serverId = 0) { if (serverId == 0) { serverId = ConfigController.PrimaryServer; } if (serverId == 0) { throw new System.Exception("There is no server with the id " + serverId.ToString("X")); } if (!Servers.ContainsKey(serverId)) { Servers.AddOrUpdate(serverId, new CoflnetServer(serverId), (sid, s) => s); } SendCommandToServer(data, Servers[serverId]); }