示例#1
0
        public override void Parse(string[] spaceSplit, string[] colonSplit,
            string fullRow)
        {
            if (spaceSplit.Count() < 10)
            {
                return;
            }
            Server upLink = Service.GetServer(spaceSplit[0]);
            if (upLink == null)
            {
                Service.AddLog("S from unknown server " + spaceSplit[0]);
                return;
            }
            string numeric = spaceSplit[7].Substring(0, 2);
            if (Service.ContainsServer(numeric))
            {
                Service.AddLog("Numeric Collision on server " + numeric);
                return;
            }
            string description = "";
            if (colonSplit.Count() > 1)
            {
                description = StringHelper.JoinArray(colonSplit, ":", 1);
            }

            Server server =
                new Server(Service, numeric, spaceSplit[2], description,
                    new UnixTimestamp(Convert.ToInt32(spaceSplit[4])), 
                    Base64Converter.NumericToInt(spaceSplit[7].Substring(2, 3)),
                    false, upLink);
            Service.AddServer(server);
            Service.SendActionToPlugins(p => p.OnNewServer(server));

            return;
        }
示例#2
0
 /// <summary>
 /// Is the server on the network?
 /// </summary>
 /// <param name="server"></param>
 /// <returns>TRUE if the server is found</returns>
 public bool ContainsServer(Server server)
 {
     lock (lockObject)
     {
         return ContainsServer(server.Numeric);
     }
 }
示例#3
0
 /// <summary>
 /// Removes a server from the server list and notifies all plugins
 /// </summary>
 /// <param name="server"></param>
 /// <param name="reason"></param>
 /// <returns>TRUE if the server is successfully removed</returns>
 public bool RemoveServer(Server server, string reason)
 {
     lock (this)
     {
         return RemoveServer(server.Numeric, reason);
     }
 }
示例#4
0
 /// <summary>
 /// Adds a server to the list of servers
 /// </summary>
 /// <param name="server"></param>
 /// <returns>TRUE if the server is successfully added</returns>
 public bool AddServer(Server server)
 {
     lock (lockObject)
     {
         if (servers.Keys.Contains(server.Numeric))
         {
             return false;
         }
         servers.Add(server.Numeric, server);
         return true;
     }
 }
示例#5
0
 /// <summary>
 /// Prepares the service for accepting plugins
 /// </summary>
 public virtual void PrepareForPlugins()
 {
     lock (lockObject)
     {
         if (MainServer == null)
         {
             MainServer = new Server(
                 this,
                 numeric,
                 name,
                 description,
                 startTimestamp,
                 Server.MaxCapacity,
                 true,
                 null
             );
             AddServer(MainServer);
         }
         PreparedForPlugins = true;
     }
 }
示例#6
0
        /// <summary>
        /// Adds a server to the network
        /// </summary>
        /// <param name="numeric"></param>
        /// <param name="name"></param>
        /// <param name="description"></param>
        /// <param name="maxUsers"></param>
        /// <param name="upLink"></param>
        /// <returns>The new server if it is successfully added 
        /// or null if not</returns>
        public IServer AddServer(string numeric, string name, string description, 
            int maxUsers, IServer upLink = null)
        {
            lock (lockObject)
            {
                if (Service.GetServer(numeric) != null)
                {
                    return null;
                }
                var newServer = new Server(Service, numeric, name, description,
                    UnixTimestamp.CurrentTimestamp(), maxUsers, true, upLink);
                newServer.Plugin = this;
                servers.Add(newServer);

                Service.AddServer(newServer);
                servers.Sort((x, y) => x.Depth - y.Depth);

                if (Service.Status == ServiceStatus.BurstCompleted)
                {
                    var command = Service.CommandFactory.CreateNewServerCommand();
                    command.Server = newServer;
                    Service.SendCommand(command, false);
                    Service.SendActionToPlugins(p => p.OnNewServer(newServer), this);
                }

                return newServer;
            }
        }