Exemplo n.º 1
0
        public void Receive(ref MinecraftClient client, GameStream stream)
        {
            VarInt protocolVersion = stream.ReadVarInt();
            string serverAddress   = stream.ReadString();
            ushort port            = stream.ReadShort();
            VarInt nextState       = stream.ReadVarInt();

            if (nextState == 1)
            {
                client.State = ConnectionState.Status;
            }
            else if (nextState == 2)
            {
                client.State = ConnectionState.Login;
            }
            else
            {
                throw new Exception("Invalid Next State - Handshake");
            }
        }
Exemplo n.º 2
0
        public static void ReceiveHandshake(Player client, GameStream stream)
        {
            VarInt protocolVersion = stream.ReadVarInt();
            string serverAddress   = stream.ReadString();
            ushort port            = stream.ReadShort();
            VarInt next            = stream.ReadVarInt();

            if (!CheckHandshakeInfo(protocolVersion, serverAddress, port, next))
            {
                return;
            }

            switch ((int)next.Value)
            {
            case 1:     // Status
                client.State = SessionState.Status;
                StatusPackets.SendStatus(client, stream);
                break;

            case 2:     // Login
                client.State = SessionState.Login;
                break;
            }
        }