-
-
Save apathyboy/1013706 to your computer and use it in GitHub Desktop.
LoginClientToken
This file contains hidden or 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
| template<typename T> | |
| struct BaseSwgPacket { | |
| void serialize(anh::ByteBuffer& buffer) const { | |
| buffer.write(T::opcount); | |
| buffer.write(T::opcode); | |
| onSerialize(buffer); | |
| } | |
| void deserialize(anh::ByteBuffer buffer) { | |
| uint16_t opcount = buffer.read<uint16_t>(); | |
| uint32_t opcode = buffer.read<uint32_t>(); | |
| if (opcount != T::opcount || opcode != T::opcode) { | |
| // @todo throw here perhaps? for now just return; | |
| return; | |
| } | |
| onDeserialize(std::move(buffer)); | |
| } | |
| virtual void onSerialize(anh::ByteBuffer& buffer) const = 0; | |
| virtual void onDeserialize(anh::ByteBuffer buffer) = 0; | |
| }; | |
| struct LoginClientId : public BaseSwgPacket<LoginClientId> { | |
| static const uint16_t opcount = 4; | |
| static const uint32_t opcode = 0x41131F96; | |
| std::string username; | |
| std::string password; | |
| std::string client_version; | |
| void onDeserialize(anh::ByteBuffer buffer) { | |
| username = buffer.read<std::string>(); | |
| password = buffer.read<std::string>(); | |
| client_version = buffer.read<std::string>(); | |
| } | |
| void onSerialize(anh::ByteBuffer& buffer) const { | |
| buffer.write(username); | |
| buffer.write(password); | |
| buffer.write(client_version); | |
| } | |
| }; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment