> servlet
I'm implementing a simple checkers game (java applets as clients + servlet) where two players can connect to the servlet and play. As I'm just beginning with applet-servlet programming, I have some problems with the proper communication.
Let's suppose the game begins and first player moves. Then I have to send his move to the servlet which should inform the other player. And here I don't know how to do that. How the servlet can pass received data to another applet, not the one that sent it? How and where should the servlet keep the info related to players so that it can recognize which one sent the data?
Fisrt: the servlet won't pass data or message to any servlet from its initiative. It will have to wait for the applet to send a request, and then will be able to send a proper response.
So, the simplest seems that your applets regularly send requests to the servlet, like "what's up?". It's the polling system ome is talking about. To recognize which player is polling, give them an id when they first access your servlet (register ?), and make that id present in every future request.
Is that clear enough ? :)
(and yes, next step is to use COMET)
链接地址: http://www.djcxy.com/p/55940.html上一篇: 如何从ISBN号获取书名?
下一篇: > servlet