Example #1
0
        public void Add(byte gsId, string ip, ushort port, InternalConnection connection)
        {
            if (!_gameServers.ContainsKey(gsId))
            {
                connection.SendPacket(new LGRegisterGameServerPacket(GSRegisterResult.Error));
                return;
            }

            var gameServer = _gameServers[gsId];

            gameServer.Ip         = ip;
            gameServer.Port       = port;
            gameServer.Connection = connection;
            connection.GameServer = gameServer;
            connection.AddAttribute("gsId", gameServer.Id);
            gameServer.SendPacket(new LGRegisterGameServerPacket(GSRegisterResult.Success));
            _log.Info("Registered GameServer {0}", gameServer.Id);
        }
        public void Add(byte gsId, List <byte> mirrorsId, InternalConnection connection)
        {
            if (!_gameServers.ContainsKey(gsId))
            {
                connection.SendPacket(new LGRegisterGameServerPacket(GSRegisterResult.Error));
                return;
            }

            var gameServer = _gameServers[gsId];

            gameServer.Connection = connection;
            gameServer.MirrorsId.AddRange(mirrorsId);
            connection.GameServer = gameServer;
            connection.AddAttribute("gsId", gameServer.Id);
            gameServer.SendPacket(new LGRegisterGameServerPacket(GSRegisterResult.Success));

            foreach (var mirrorId in mirrorsId)
            {
                _gameServers[mirrorId].Connection = connection;
                _mirrorsId.Add(mirrorId, gsId);
            }

            _log.Info("Registered GameServer {0}", gameServer.Id);
        }