}
Would always have values for M and A. Even if they were not provided in the JSON object received
If the field is not a pointer reference then the json decoder will populate the field's value
with its defaults, and you would need another system other than checking for nil to know if
a specific message category was received.
The following would work though. MessageIn wasn't the best example since there was only one type of
message category that could be received.
type json struct {
M *MessageIn
A *MsgPlayerAction
}
MessageGameUpdate might be a little better example since it shows multiple items that could
be populated. https://github.com/jasondelponte/Apollo/blob/master/messages.go#L58.
Once the MessageGameUpdate is encoded to JSON only the fields that aren't nil will
be present in the JSON object when its received.
I've been thinking of a couple other ideas, but they seem to all to start to get a bit
hacky and fragile. Like custom message format where the message id is outside of the json blob.
ex: MsgId:<json>:MsgTerm. Could be useful for really long messages or poor network connection
since websocket is streaming
If you really have no idea what kind of message you'll be receiving like when using a third party
client/api a map[string]interface{} might be the easiest solution to determine the message received.
So that it can parsed a second time using a more specific structure.