Skip to content

Commit

Permalink
Add id to message header
Browse files Browse the repository at this point in the history
  • Loading branch information
Jacquwes committed Mar 24, 2023
1 parent 928183a commit 494e103
Showing 1 changed file with 28 additions and 1 deletion.
29 changes: 28 additions & 1 deletion Server/Message.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,17 +18,44 @@ namespace SocketMessages

switch (uint8_t messageType_ = buffer[0])
{
using enum SocketMessages::MessageType;
using enum MessageType;

case static_cast<int>(AcknowledgeMessage):
messageType = AcknowledgeMessage;
break;

case static_cast<int>(HelloMessage):
messageType = HelloMessage;
break;

case static_cast<int>(IdentifyMessage):
messageType = IdentifyMessage;
break;

case static_cast<int>(KeepAliveMessage):
messageType = KeepAliveMessage;
break;

case static_cast<int>(SendChatMessage):
messageType = SendChatMessage;
break;

case static_cast<int>(ReceiveChatMessage):
messageType = ReceiveChatMessage;
break;

case static_cast<int>(ErrorMessage):
messageType = ErrorMessage;
break;

default:
messageType = InvalidMessage;
break;
}

uint64_t id;
std::memcpy(&id, &buffer[sizeof(messageType) + sizeof(bodySize)], sizeof(id));
messageId = Snowflake{ id };
}

std::vector<uint8_t> MessageHeader::Serialize() const
Expand Down

0 comments on commit 494e103

Please sign in to comment.