/// <summary> /// Called to register a new GameServer to servers list /// </summary> /// <param name="gs"></param> public void OnRegisterGameServer(ushort index, GameServer gs, string key) { ConsoleUtils.ShowInfo("Game Server '{0}' ({1}:{2}; index:{3}) is trying to connect...", gs.Name, gs.IP, gs.Port, index); if (this.GameServers.ContainsKey(index)) { // Is index available? ConsoleUtils.ShowWarning("Failed to add server to server list, duplicated index '{0}'.", index); GamePackets.Instance.RegisterResult(gs, 1); return; } else if (!key.Equals(Settings.AcceptorKey)) { // Is acceptor key valid? ConsoleUtils.ShowWarning("Connection refused, invalid Acceptor Key. (Received: {0}; Expected: {1})", key, Settings.AcceptorKey); GamePackets.Instance.RegisterResult(gs, 2); return; } gs.Index = index; GameServers.Add(index, gs); ConsoleUtils.ShowInfo("Connection with Game Server '{0}' stabilished.", gs.Name); GamePackets.Instance.RegisterResult(gs, 0); return; }
/// <summary> /// Called when a Game-Server disconnects from Auth /// </summary> /// <param name="gs"></param> internal void OnGameServerDisconnects(GameServer gs) { ConsoleUtils.ShowInfo("Game-Server '{0}' disconnected.", gs.Name); if (!GameServers.ContainsKey(gs.Index)) { ConsoleUtils.ShowError("Failed to remove Game-Server from server list, invalid index {0}", gs.Index); return; } GameServers.Remove(gs.Index); gs.NetData.ClSocket.Close(); }