2
Answers

Sending (and then handling messages) to a server

Alex

Alex

16y
2.5k
1
Good morning,

Say I have various types of messages to send across the network, but obviously I can only send them as an object. How do I split where the various messages are sent when they get to the server?

I've been going around in circles, and the obvious way (in my head) to handle this is to have some sort of header (using an interface), and then do a switch depending on what's in the header, and cast the object to the specific type.

But something's telling me this is a bad way of doing it, it doesn't feel very OO. any suggestions?

Alex
Answers (2)