Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // [0] - protocol type
- // [1...4] - packet number
- // [5...512] - email(254 symbols in UTF-8)
- // [513...514] - email length
- // [515...578] - password(32 symbols in UTF-8)
- // [579] - password length
- ...
- const std::wstring email = L"player@gmail.com";
- const std::wstring password = L"difficult_password";
- std::unique_ptr<Protocol::LoginPacket> packetToServer = std::make_unique<Protocol::LoginPacket>();
- packetToServer->setPacketNumber(mPacketNumber++);
- packetToServer->setEmailSize((std::int16_t) email.size());
- packetToServer->setPasswordSize((std::int8_t) password.size());
- packetToServer->setEmail(email.data());
- packetToServer->setPassword(password.data());
- mConnection.sendBuffer(packetToServer->toBuffer(), sizeof(Protocol::LoginPacket));
- ...
- ...
- private final static byte POSITION_EMAIL = 5; // index
- private final static short SIZE_EMAIL = 254 * Primitives.CHAR_SIZE; // bytes
- private final static short POSITION_OF_SIZE_EMAIL = 513; // index
- private final static byte SIZE_OF_EMAIL_SIZE = Primitives.SHORT_SIZE; // bytes
- ...
- public String getEmail(){
- return new String(buffer, POSITION_EMAIL, ByteBuffer.wrap(buffer, POSITION_OF_SIZE_EMAIL, SIZE_OF_EMAIL_SIZE).getShort() * Primitives.CHAR_SIZE);
- }
- ...
- if ("player@gmail.com".equals(protocol.getPassword())) {
- ...
- }
Add Comment
Please, Sign In to add comment