コード例 #1
0
 /// <summary>
 /// Displayes a list of workds
 /// </summary>
 /// <param name="args">Arguments</param>
 static void ShowWorld(string[] args)
 {
     Console.WriteLine("");
     Console.WriteLine("Worlds\tPlayers\tIp");
     Console.WriteLine("================================================");
     foreach (KeyValuePair <byte, ServerInfo2> pair in ServerManager2.Instance.server)
     {
         ServerInfo2 info = pair.Value;
         Console.WriteLine("{0}\t{1}\t{2}", info.name, info.Players, info.IP);
     }
 }
コード例 #2
0
        // 0x000B
        public void CM_RELEASESESSION(CMSG_RELEASESESSION cpkt)
        {
            Trace.TraceWarning(string.Format("Release session: {0}", cpkt.Session));
            //Update the delay
            ServerInfo2 info = null;

            if (Singleton.Database.ReleaseSessionId(cpkt.Session) &&
                ServerManager2.Instance.server.TryGetValue(WorldId, out info))
            {
                info.Players = info.Players > 0 ? info.Players - 1 : 0;
            }
        }
コード例 #3
0
        // 0x000A
        public void CM_PONG(CMSG_PONG cpkt)
        {
            //Delay between ping and pong reply
            int delay = Environment.TickCount - PingTick;

            //Update the delay
            ServerInfo2 info = null;

            if (ServerManager2.Instance.server.TryGetValue(WorldId, out info))
            {
                info.LastPing = delay;
            }
        }
コード例 #4
0
        static void SessionKill(string[] args)
        {
            if (args.Length != 3)
            {
                Console.WriteLine("Wrong argument count");
                return;
            }

            LoginResult result;

            if (!Singleton.Database.Login(args[2], out result))
            {
                Console.WriteLine("User does not exists");
                return;
            }
            else
            {
                ServerInfo2 info = null;
                if (result.ative_session > 0)
                {
                    //SERVER DOES NOT EXISTS
                    if (!ServerManager2.Instance.server.TryGetValue((byte)result.last_server, out info))
                    {
                        Console.WriteLine("Server does not exists");
                    }
                    //CHECK IF SERVER IS ALIVE
                    else if (info.client != null && info.client.IsConnected)
                    {
                        info.client.SM_KILLSESSION(result.ative_session);
                    }
                    else
                    {
                        Console.WriteLine("Server is not online");
                    }
                }
            }
        }
コード例 #5
0
        // 0x0001
        public void CM_WORLDINSTANCE(CMSG_WORLDINSTANCE cpkt)
        {
            ServerInfo2 info    = null;
            byte        error   = 0;
            byte        WorldId = 0;

            try
            {
                //socket.RemoteEndPoint.
                IPEndPoint IPEndPoint = (IPEndPoint)socket.RemoteEndPoint;
                WorldId = cpkt.WorldId;

                //SERVER DOES NOT EXISTS
                if (!ServerManager2.Instance.server.TryGetValue(WorldId, out info))
                {
                    error = 3;
                }
                //IF PROOF IS VALID
                else if (info.proof != cpkt.Proof)
                {
                    error = 1;
                }
                //CHECK IF SERVER IS ALIVE
                else if (info.client != null && info.client.IsConnected && cpkt.IsReconnected == 0)
                {
                    error = 2;
                }
                //IF EVERYTHING IS OKAY
                else
                {
                    this.WorldId = WorldId;
                    info.GenerateKey();
                    info.client           = this;
                    info.MaxPlayers       = cpkt.MaximumPlayers;
                    info.Players          = 0;
                    info.InMaintainceMode = false;
                    info.IP          = IPEndPoint.Address;
                    info.Port        = cpkt.Port;
                    info.RequiredAge = cpkt.RequiredAge;

                    Console.WriteLine("world connection established");

                    if (cpkt.IsReconnected == 0)
                    {
                        Singleton.Database.ClearWorldSessions(this.WorldId);
                    }

                    SMSG_SETRATES spkt = new SMSG_SETRATES();
                    spkt.IsAdDisplayed = Managers.ConsoleCommands.ShowAdvertisment ? (byte)1 : (byte)0;
                    this.Send((byte[])spkt);
                }
            }
            finally
            {
                Thread.Sleep(500);
                SMSG_WORLDINSTANCEACK spkt = new SMSG_WORLDINSTANCEACK();
                spkt.Result = error;
                if (error == 0)
                {
                    spkt.NextKey = info.KEY;
                }
                this.Send((byte[])spkt);
            }
        }