| 776 | // packet handling, client-side, initial handshake: |
| 777 | |
| 778 | bool cConnection::HandleClientHandshake(void) |
| 779 | { |
| 780 | // Read the packet from the client: |
| 781 | HANDLE_CLIENT_PACKET_READ(ReadVarInt, UInt32, ProtocolVersion); |
| 782 | HANDLE_CLIENT_PACKET_READ(ReadVarUTF8String, AString, ServerHost); |
| 783 | HANDLE_CLIENT_PACKET_READ(ReadBEShort, short, ServerPort); |
| 784 | HANDLE_CLIENT_PACKET_READ(ReadVarInt, UInt32, NextState); |
| 785 | m_ClientBuffer.CommitRead(); |
| 786 | |
| 787 | Log("Received an initial handshake packet from the client:"); |
| 788 | Log(" ProtocolVersion = %u", ProtocolVersion); |
| 789 | Log(" ServerHost = \"%s\"", ServerHost.c_str()); |
| 790 | Log(" ServerPort = %d", ServerPort); |
| 791 | Log(" NextState = %u", NextState); |
| 792 | |
| 793 | // Send the same packet to the server, but with our port: |
| 794 | cByteBuffer Packet(512); |
| 795 | Packet.WriteVarInt(0); // Packet type - initial handshake |
| 796 | Packet.WriteVarInt(ProtocolVersion); |
| 797 | Packet.WriteVarUTF8String(ServerHost); |
| 798 | Packet.WriteBEShort(m_Server.GetConnectPort()); |
| 799 | Packet.WriteVarInt(NextState); |
| 800 | AString Pkt; |
| 801 | Packet.ReadAll(Pkt); |
| 802 | cByteBuffer ToServer(512); |
| 803 | ToServer.WriteVarUTF8String(Pkt); |
| 804 | SERVERSEND(ToServer); |
| 805 | |
| 806 | m_ClientProtocolState = (int)NextState; |
| 807 | m_ServerProtocolState = (int)NextState; |
| 808 | |
| 809 | return true; |
| 810 | } |
| 811 | |
| 812 | |
| 813 |
nothing calls this directly
no test coverage detected