Disconnect() public method

public Disconnect ( ) : void
return void
        void ProcessPolicyFile()
        {
            var     s   = new NetworkStream(skt);
            NWriter wtr = new NWriter(s);

            wtr.WriteNullTerminatedString(@"<cross-domain-policy>
    <allowed-access-from domain=""*"" to-ports=""*"" />
</cross-domain-policy>");
            wtr.Write((byte)'\r');
            wtr.Write((byte)'\n');
            parent.Disconnect();
        }
Ejemplo n.º 2
0
 void ProcessEscapePacket(EscapePacket pkt)
 {
     try
     {
         World world = RealmManager.GetWorld(Player.Owner.Id);
         if (world.Id == World.NEXUS_ID)
         {
             SendPacket(new TextPacket()
             {
                 Stars      = 52,
                 BubbleTime = 0,
                 Name       = "You stupid?",
                 Text       = "Please do not bother Nexusing in Nexus..."
             });
             return;
         }
         Reconnect(new ReconnectPacket()
         {
             Host   = "",
             Port   = 2050,
             GameId = World.NEXUS_ID,
             Name   = "Nexus",
             Key    = Empty <byte> .Array,
         });
     }
     catch
     {
         Console.ForegroundColor = ConsoleColor.Red;
         Console.Out.WriteLine("[Error while sending EscapePacket, Check ClientProcessor.cs]");
         Player.SaveToCharacter();
         psr.Disconnect();
         Console.ForegroundColor = ConsoleColor.White;
     }
 }
Ejemplo n.º 3
0
        /* Makes various checks to see if client is allowed to connect.
         * Returns null on success, otherwise return value contains
         * discription of error.
         */
        private string OkToConnect(HelloPacket pkt)
        {
            string retMsg = null;

            ConnectedBuild = pkt.BuildVersion;

            // check client version
            if (!ConnectedBuild.StartsWith(clientVer))
            {
                ConnectionFailed(retMsg = "Wrong build version.");
            }

            // has valid account?
            else if ((account = db.Verify(pkt.GUID, pkt.Password)) == null)
            {
                ConnectionFailed(retMsg = "Invalid account.");
            }

            // ip banned?
            else if (ip.Banned)
            {
                ConnectionFailed(retMsg = "IP banned.");
            }

            // account banned?
            else if (account.Banned)
            {
                ConnectionFailed(retMsg = "Account banned.");
            }

            // server full?
            else if (RealmManager.Clients.Count >= RealmManager.MAX_CLIENT)
            {
                ConnectionFailed(retMsg = "Server full.");
            }

            // valid gameId?
            else if (RealmManager.GetWorld(pkt.GameId) == null)
            {
                // invalid world... send to nexus instead
                pkt.GameId = World.NEXUS_ID;
            }

            // account already connected? disconnect if so
            else if (AccountConnected(account.AccountId))
            {
                ConnectionFailed(retMsg = "Account in use... ");
                ClientProcessor target = RealmManager.Clients[account.AccountId];
                target.Disconnect();
            }

            return(retMsg);
        }