Is there any design pattern or something else for the network communication using Socket. I mean what i always do is :
- I receive a message from my client or my server
- I extract the type of this message (f.e : LOGIN or LOGOUT or CHECK_TICKET etc ...)
- And i test this type in a switch case statement
- Then execute the suitable method for this type
this way is a little bit borring when u have a lot of type of message. Each time i have to add a type, i have to add it in the switch case. Plus, it take more machine operations when you have hundred or thousands type of message in your protocol (due to the switch case).
Thanks.
Aucun commentaire:
Enregistrer un commentaire