Beispiel #1
0
        public void SendPacket(PacketBase packet)
        {
            if (!IsActive) return;

            packet.Send(_stream);
        }
Beispiel #2
0
 void FirePacket(PacketBase packet)
 {
     if (_subscriptions.ContainsKey(packet.Id))
     {
         _subscriptions[packet.Id](packet);
     }
     else if (UnsubscribedPacket != null)
     {
         UnsubscribedPacket(packet);
     }
     else
     {
         throw new NotSupportedException("Unhandled packet");
     }
 }
Beispiel #3
0
        void ShakeHands(PacketBase packet)
        {
            if (_loggedIn) return;

            var hsResp = (HandshakeResponse) packet;

            var connectionHash = hsResp.ConnectionHash;
            Console.WriteLine("Got hash: " + connectionHash);

            // No authentication
            if (connectionHash == "-")
            {
                Console.WriteLine("No name authentication needed");
                return;
            }

            Console.Write("Authorizing... ");

            using(var wc = new WebClient())
            {
                wc.DownloadString("http://www.minecraft.net/game/joinserver.jsp?user="******"&sessionId=" + _loginResponse[3] + "&serverId=" + connectionHash);
            }

            Console.WriteLine("OK");

            Console.WriteLine("Joining...");

            _handler.SendPacket(new LoginRequest
                                    {
                                        Protocol = Protocol,
                                        Username = _username,
                                        Password = "",
                                        MapSeed = 0,
                                        Dimension = 0
                                    });

            _loggedIn = true;
        }