PlayN客户端与服务器的协作 [英] Collaboration from PlayN client with server

查看:157
本文介绍了PlayN客户端与服务器的协作的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经在PlayN中编写了一个游戏,该游戏必须与带有Seam的JavaEE-Server通信. 首先,我只需要在HTML5中运行游戏即可.

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.

当前问题是PlayN客户端与JavaEE服务器之间的通信

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

1)首先,我尝试通过PlayN.net()接口进行通信,以使用JSON交换信息.由于PlayN在端口8888上运行,而服务器在8080上运行,因此我正确地遇到了同源策略问题.

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)现在,我正在寻找一个可行的解决方案.您会推荐哪一个?还有其他想法吗?

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

a)我正在尝试使用

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

b)我尝试将playN运行在与服务器相同的端口上,即8080-因此我不再对同源策略有任何疑问.问题:HTML5 playN应用程序可以在同一端口上运行吗? 因此,当我使用Eclipse启动JavaEE-Server时,它还应该同时在端口8080上启动PlayN Web应用程序,对吧?

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?

这可能吗?

c)最hacky的解决方案(当前有效):服务器将JSON-String写入文件,而playN客户端将文件读出.

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

您推荐什么?我想实施解决方案2,因为它是最干净的解决方案,但我不知道它有多难以及它是如何工作的.

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.

感谢您的帮助!

推荐答案

我认为问题是您正在运行" PlayN,并且与Seam服务器分离.

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

如果我对您的理解正确,那么您可以执行Maven任务以HTML格式运行游戏,而另一方面,您运行Jboss(或任何Java EE服务器),则应该运行

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

这将引起游戏大战,然后将这场大战发布到您的Java EE服务器上,然后您可以毫无问题地使用 PlayN.net 程序包,并在单个服务器上运行

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

这篇关于PlayN客户端与服务器的协作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆