Hey guys, I'm using GWT to code a simple multiplayer board game. And while I was coding the question came up to my mind:
At first I though my client could simply communicate with the server via RemoteServices calls, so if a client wanted to connect to a game he could do as follows:
- joinGame (String playerName, String gameName)
And the server implementation would do the necessary processing with the argument's data. In other words, I would have lots of RemoteService methods, one for each type of message in the worst case.
I thought of another way, which would be creating a Message class and sub-classing it as needed. This way, a single remoteService method would be enough:
- sendMessage (Message m)
The messages building and interpreting processing too would be done by specialized classes. Specially the building class could even be put in the gwt-app shared package.
That said, I can't see the benefits of one or another. Thus I'm not sure if I should do one way or another or even another completely different way.
One vs other, who do you think it is better (has more benefits in the given situation)?
EDIT: A thing I forgot to mention is that one of the factors that made me think of the second (sendMessage) option was that in my application there is a CometServlet that queries game instances to see if there is not sent messages to the client in its own message queue (each client has a message queue).