Ejemplo n.º 1
0
        public void RegisterWorld(ushort serverId, string name, sbyte type, string host, int port)
        {
            ServerRecord world = ServerRecord.GetWorldServer(serverId);

            if (world != null)
            {
                if (world.Host != host || world.Port != port || world.Name != name || world.Type != type)
                {
                    world.Host = host;
                    world.Port = port;
                    world.Name = name;
                    world.Type = type;

                    logger.White("Updating server informations...(" + name + ")");
                    world.UpdateInstantElement();
                }

                this.SetServerStatus(serverId, ServerStatusEnum.STARTING);
                logger.White(string.Format("Server Registred : {0} ({1}:{2})", world.Name, world.Host, world.Port));
            }
            else
            {
                var newWorld = new ServerRecord(serverId, name, type, host, port);

                if (ServerRecord.CanBeAdded(newWorld))
                {
                    ServerRecord.AddWorldServer(newWorld);
                    this.SetServerStatus(serverId, ServerStatusEnum.STARTING);
                    logger.White(string.Format("New server added : {0} ({1}:{2})", newWorld.Name, newWorld.Host, newWorld.Port));
                }
                else
                {
                    logger.Alert("A new server try to join Auth but he is not allowed (Id or Ip and Port are reserved)");
                }
            }
        }