Created
June 4, 2011 21:56
-
-
Save Kronos11/1008402 to your computer and use it in GitHub Desktop.
LoginClientToken
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
struct LoginClientToken | |
{ | |
LoginClientToken(anh::ByteBuffer& buffer) | |
{ | |
deserialize(buffer); | |
} | |
LoginClientToken(anh::ByteBuffer session_key_, int32_t account_id_, std::string account_username_) | |
: session_key(session_key_) | |
, account_id(account_id_) | |
, account_username(account_username_) | |
{ | |
} | |
anh::ByteBuffer session_key; | |
int32_t account_id; | |
std::string account_username; | |
static uint32_t crc() { return 0xAAB296C6; } | |
static uint16_t operand_count() { return 4; } | |
void serialize(anh::ByteBuffer& buffer) { | |
buffer.write<uint16_t>(operand_count()); | |
buffer.write<uint32_t>(crc()); | |
buffer.write<uint32_t>(session_key.size()); | |
buffer.append(session_key); | |
buffer.write<uint32_t>(account_id); | |
buffer.write<std::string>(account_username); | |
} | |
void deserialize(anh::ByteBuffer& buffer) { | |
session_key = anh::ByteBuffer(buffer.data(), buffer.read<uint32_t>()); | |
buffer.read_position(buffer.read_position() + session_key.size()); | |
account_id = buffer.read<int32_t>(); | |
account_username = buffer.read<std::string>(); | |
} | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment