File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Web Services and the fly likes battleships game with JAX-WS Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of EJB 3 in Action this week in the EJB and other Java EE Technologies forum!
JavaRanch » Java Forums » Java » Web Services
Bookmark "battleships game with JAX-WS" Watch "battleships game with JAX-WS" New topic
Author

battleships game with JAX-WS

Jan Schumacher
Greenhorn

Joined: Apr 29, 2007
Posts: 2
Hi everybody,

I want to write a simple 2 player battleships game using jax-ws. so there is a server running in the glassfish appServer and clients can connect to is oever SOAP.

now i am a little confused. let's consider the scenario, that client1 (c1) wants to shoot, so it calls the servers WebMethod shoot(xCord, YCord, playerID). now c1 has to wait until c2 has made his turn.

i tried to implement this using async calls using call-back functions ... which of course did not work, since c1 gets called back, when it shot, but i want c2 to be notified, that it can make a turn now.

what is the best way to do this?

as i said, i am a little confused and i hope that i could make myself clear.

Cheers, jansch
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 39535
    
  27
Welcome to JavaRanch.

I don't think WS are a good fit for this problem. WS are server-centric, with clients making requests to which the server responds; battleship is a peer-to-peer scenario, with both sides being equals, so to speak. While it's possible to make asynchronous calls, to which the server responds at some later time, this may be difficult in practice due to firewalls and NAT.

Now, if you had just one player, who battles a computer opponent accessed via WS, that would be a much better fit. Plus, you'd get to think up and implement a strategy of how to play the game


Ping & DNS - updated with new look and Ping home screen widget
Jan Schumacher
Greenhorn

Joined: Apr 29, 2007
Posts: 2
yes, that makes sens ... i already implemented everything using rmi, where i can call methods on the client from the server.

but it's got to work with JAX-WS as well ... maybe with a dispatcher ... i am lost somehow

i could always poll the server, but that is just not nice.

Cheers, Jan
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: battleships game with JAX-WS
 
Similar Threads
Garbage collection doubt
protected and default constructor
how many objects will be eligible for garbage collection
Uno: Returning control to the Uno object from a player object
Garbage Collection