I’d like to implement a simple chess peer to peer network application : one instance of the program may register friends player, and when one friend is “connected” (I mean both available by another program instance and registered as friend), I can ask him to play a game.
As I know J2SE language, as well as Swing framework, I tried to start coding, using Sockets. The problem is that I need a way to
- register my friends (or other accounts)
- get the friend ip, for creating a socket (it will be the same problem on the other side) : with the problem of dynamic ip adresses.I mean that a serialized adress may not be valid anymore
- be informed that the other side has “connected”
I think that first and third point can be resolved if I use a PHP server which will have all informations for all registered users.
This is how the application should work :
- First, before trying to connect each other, the users must register an account on a PHP server that I’ll have to implement (with MySQL database)
- When launching the application, the user logins by giving its username and password. So that the application will be able to retrieve friends (and stats for example) thanks to the server
- When two friends are ready to play together, the server give all needed informations (such as ip adress) to both player application instance.
My main difficulties will be for the (de)serialization of dynamic IP Adresses, and for retrieving informations about a user on the PHP server.
What do you suggest ?
5
Instead of peer to peer, why not have a central server in which connections are handled and the server’s responsibility is to connect the peers together. This also facilitates easier security, acquisition of IP Address and other information that could be kept for storage by the server.
A nice threaded-server in which each connection causes server to spawn a thread and connect that thread to another and thus set up peer to peer would be cool.
This virtualized peer to peer would be simpler and easier to manage in my opinion.
3