Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Client-server game in Java with applets

I have to implement a simple tour client-server game in Java. Unfortunately, I'm just beginning with network programming and have some problems with choosing an apropriate solution.

Let's assume I'm creating a chess game where two clients can connect to the server, authenticate with their username and passwords and play. The clients must be programmed as applets (thin clients), but I don't know what I should use as a server.

I mean, I've read about several different possibilities like RMI, sockets, servlets, but still don't know which one fits bets my needs. I'm a bit confused because I don't fully understand how the communication would be carried out.

Should I create an executable server which would run all the time on the server and wait for the players? This seems to me like an odd way. Or is there any easier way to do so, e.g. can I make a servlet and put it on Tomcat server so that the server would be run only if there are any players? Could that servlet communicate with applets (clients) and vice versa?*

I'd be really grateful for some tips.

like image 505
syntax_error Avatar asked Oct 04 '11 15:10

syntax_error


1 Answers

can I make a servlet and put it on Tomcat server so that the server would be run only if there are any players

The Tomcat instance would run anyways, otherwise players couldn't connect to it.

What you could do is to provide a server that starts a new game instance when players connect. The server itself would have to always run.

In terms of technology, I'd suggest you use whatever you feel comfortable with. Don't care about performance yet but try and get started.

So if you already have some knowledge with a communication technology, try and use that. Just be aware of the limitations and take those into account (e.g. message formats, push/pull communication etc.).

like image 108
Thomas Avatar answered Oct 21 '22 06:10

Thomas