简体   繁体   English

Java服务器android客户端

[英]Java server android client

I'm making a multiplayer game on android, which will communicate with a Java server. 我正在Android上制作多人游戏,它将与Java服务器通信。 (and the server communicate with a database). (并且服务器与数据库进行通信)。 There will be a lot of clients... 会有很多客户...
I'm started with a webapplication with glassfish server, generated the entity classes from the database, then generated facadeREST classes from entities. 我从带glassfish服务器的Web应用程序开始,从数据库生成实体类,然后从实体生成facadeREST类。 I tried to use HTTP request-response communication, and it was simple. 我尝试使用HTTP请求-响应通信,这很简单。 But! 但! There is a problem: 有一个问题:

Only the client can start communication, the server can only watch, and response for the requests. 只有客户端可以开始通信,服务器只能监视并响应请求。 Several times, I need the server to start the communication with some client. 几次,我需要服务器开始与某些客户端的通信。 With HTTP request, I can make only something like that: the client send a request in every 10 sec, and the server response, if there is a message for this client. 对于HTTP请求,我只能做出这样的事情:客户端每10秒发送一次请求,如果该客户端有消息,则服务器响应。 But this is not the way I'd like to do it. 但这不是我想要的方式。 I'm sure that there is a better solution. 我相信有更好的解决方案。

I'm looking for a way, that is simple. 我正在寻找一种简单的方法。 it would be good, if I could use glassfish or other servers to solve the multithreading. 如果可以使用glassfish或其他服务器来解决多线程问题,那将是很好的。

What you need my friend is C2DM ! 您需要我的朋友是C2DM

It'll cut the need for your clients to keep polling, instead you have the cloud initiate the communication via push notifications. 这样可以减少客户继续轮询的需求,而是让云通过推送通知启动通信。

In regards to application server, if your app follows Java EE standards then you should be able to deploy it to any old Java EE container. 关于应用程序服务器,如果您的应用程序遵循Java EE标准,那么您应该能够将其部署到任何旧的Java EE容器中。 I'd recommend taking advantages of the free Java hosting on offer by CloudBees , just drop in your WAR as you would onto glassfish. 我建议您利用CloudBees提供的免费Java托管,只需像穿上玻璃鱼一样放下WAR。

In regards to what your application actually needs to do, I can't advise since you didn't give any specifics :S 关于您的应用程序实际需要做什么,我不建议您这样做,因为您没有提供任何详细信息:S

...And no, I don't work for Cloudbees, I just think they're awesome ...而且不,我不为Cloudbees工作,我只是认为它们很棒

WebView中的NodeJS就是答案

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM