views:

385

answers:

6

I've been developing a small card game which is called "Tarneeb". The game itself looks like Bridge card game but with different rules. Anyway, i finished the entire game as a standalone desktop application using Java 6. This is a picture of the game. Anyway, i now need to transform that into a web app with multiplayer capabilities, so the users can for an example make a new room and join existing rooms where the game is played. Unfortunately, I have no idea on networking in Java but i searched quite a lot and i found some other Java products that may help me (JavaFX, JSP, GlassFish) but i still couldn't figure out what i exactly needed to accomplish my task. All i need right now is the direction to head to and i will do my research and hopefully learn the new skills needed.

+1  A: 

As you might have a lot of interaction and a lot of updates which I should - correct me if I'm wrong - be at the client as fast as possible, I'd suggest having a look at Cometd which keeps the http connection open to each client and pushes the updates from the server to the client. If you're using jetty as webserver (and thus its "continuations") it's even highly scalable.

msparer
A: 

First, learn what a "web site" and "web application" are.

Do the tutorials: http://java.sun.com/developer/onlineTraining/index.jsp

Watch the Glassfish Tutorials: http://java.sun.com/javaee/overview/screencasts.jsp

Once you've done all the tutorials, you will have built a web application.

After you've built the tutorial web application, you can build your web application.

S.Lott
+1  A: 

The thing is, there isn't one standard way of doing this which you need to read up on.

How do you want to implement this web application? As an applet? Using standard web pages? As a web start application which people have to download?

The last option would allow you to re-use most of your existing code. If you go with that option it may be worth you looking into RMI as that will probably fit in with your existing architecture.

But otherwise, as S.Lott pointed out, you need to go and learn how to make web applications before doing anything else. Those tutorials would be a good start, also you should definitely learn (X)HTML, JavaScript, and a Java web technology such as JSPs, JSF, or Struts. Exactly what you need will depend on your requirements, without more details it's diffiult to recommend one.

Phill Sacre
What will be the difference for me and the end-user from using those different ways ?
Salem Sayed
+2  A: 

Other answers have already pointed you to some resources.

But the biggest problem you will likely have is that it is usually impossible (or extremely time consuming up to a complete rewrite) to "add" multiplayer capabilities afterwards if you didn't plan the architecture accordingly.

Foxfire
A: 

Web apps are very badly suited for the kind of realtime interaction you have in a card game. Yes, it can be done, but it will involve dirty hacks and you'll always have problems with high latency and broken connections. And of course you'll have to completely rewrite most of your app.

If there a possibility of running the game as a Java applet? That would make your job much easier (enable much more reuse) and the end result more usable.

Michael Borgwardt
I can't see why it can't be make as an applet, i have no experience with applets, but what problems you think will arise from using them ?!
Salem Sayed
Pretty much the only problem is that it requires users to have Java installed on their computers. However, since Java 6u10 with the introduction of the Java kernel und the deployment toolkit, this has become much less of an issue: http://java.sun.com/developer/technicalArticles/javase/java6u10/
Michael Borgwardt
A: 

There is no way to port a client based app into a web app quickly. Depending on how you want to go about it, it sounds like you either need to pursue a JSP/Javascript solution or a JavaFX solution. JavaFX actually allows for smoother (smoother than JSP/Javascript, but still going to take more than an afternoon =D ) porting of client based apps, but it has a steeper learning curve than JSP/Javascript technology in general. An interesting note here is that JavaFX isn't just a web app language. If you had coded your initial client based app in JavaFX, you would have about 50% of the work done.

JavaFX

Ross