Pianting the piece using the paint() method is not going to work.Because when we pass the objects through the web service no way to trace the image.
And that's where you go wrong.
1) you could actually send the image data (but don't).
2) you should not send the image data, instead only sending moves (and maybe board positions) and take the image from the local machine you're running on (from a jarfile, cached when first needed, is a good way).
jwenting
duckman
8,392 posts since Nov 2004
Reputation Points: 1,662
Solved Threads: 337
You need a way to connect the games in real time; painting the image is really the last of your concerns!
As jwenting said, you only need to pass player moves across the network; either as a stream of events or a sequence of moves that the client side program(s) can interpret into the present position of each piece.
You can use a port listening/telnet type system to connect the two games, or have them connect to a data resource on the internet and use it like a pipe.
The methods you use will influence the way users start a game, and the overall latency; I'd suggest using an online/text database that represents the actions of a single game rather than connecting clients directly (it doesn't require IP trading) and storing/sending the whole sequence of moves rather than a stream of moves (it's quite important that all data sent between users arrives at the other end in a game like checkers).
The actual means of sending the data over the Internet is maybe too flexible, you could connect to an FTP server to read/write the file, connect to a port on your server and send it a message to write/return the contents of the file, write a CGI script that the applications can execute... hmm, can't think of another raw method.
Java maybe (probably) has an interface that simplifies this kind of thing. Look in the java.net package or google something like... "java client transaction", "java server transaction", "java port transaction", "java client communication", or even "send data between two java applications on two different machines"
EDIT: infact, the search "java network communication" gives much better results!
Hope that helps, I really doubt anyone will post code, its too specific a request.
MattEvans
Veteran Poster
1,386 posts since Jul 2006
Reputation Points: 522
Solved Threads: 64
You can connect the two clients by using Socket and ServerSocket classes. Your ServerSocket would listen for incoming events. Basically, the only thing each client has to listen for a "playerMoved" event. Update the opponent's position on your side. Each client should handle the logic of the game. So if player A moves a checker which jumps over a player B's checker, the only data you send from A to B is that the piece had moved. Player B's program should see that his checker was jumped and should run the appropriate action. No need for A to tell B that there was a jump.
The only data that really needs to be sent is anything that isn't predictable, such as player controls or random events.
And as Jwenting said, don't share image data.
Phaelax
Practically a Posting Shark
858 posts since Mar 2004
Reputation Points: 92
Solved Threads: 51