Search code examples
playn

Collaboration from PlayN client with server


I have written a game in PlayN, which has to communicate with a JavaEE-Server with Seam. First of all I only need the game running in HTML5.

The current issue is the communication between the PlayN-client and the JavaEE-Server

1) First I tried to communicate over the PlayN.net() interface exchanging information using JSON. Since PlayN is running on port 8888 and the server on 8080 I correctly run into problems with the same-origin-policy.

2) Now I'm looking for a working solution. Which one would you recommend? Do you have other ideas?

a) I'm trying to work with RPC as described in How to handle RPCs in client-server PlayN game? , using GWT-syncproxy.

b) I try that playN runs on the same port as the server i.e. 8080 - so I don't have problems with the same-origin-policy any more. Question: Can the HTML5 playN app run on the same port? So when I start the JavaEE-Server using Eclipse it should also start the PlayN web application, both on port 8080, right?

Is this possible?

c) The most hacky solution (currently working): The server writes the JSON-String into a file and the playN client reads this file out.

What do you recommend? I'd like to implement solution 2, since it is the cleanest solution, but I don't know how hard it is and how it works.

Thanks for your help!


Solution

  • I think the problem is that you are "running" PlayN, separated from your Seam server.

    If I understood you correctly, you execute the Maven task to run your game as HTML and on the other hand you run Jboss (or whatever Java EE server), what you should do is run

    mvn package

    which will create the war of the game, and then publish that war on your Java EE server, then you can use the PlayN.net package with no problems whatsoever, running in a single server