Created
February 17, 2023 09:12
-
-
Save nboutin/1778e540c182f259c4c973a74d4a80c9 to your computer and use it in GitHub Desktop.
Handling system for stream packet
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
enum class MessageType : char { | |
Add = 'A', | |
Modify = 'M', | |
Delete = 'D', | |
}; | |
void on_message(const MessageHeader& hdr, const void* payload) | |
{ | |
switch(hdr.type) | |
{ | |
case MessageType.Add: | |
return handleAdd(payload); | |
case MessageType.Modify: | |
return handleModify(payload); | |
// no-default here to catch by at compile time new value in MessageType enumeration. | |
} | |
} | |
void handleAdd(const void* payload); | |
void handleModify(const void* payload); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment