简体   繁体   中英

Java server android client

I'm making a multiplayer game on android, which will communicate with a Java server. (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. I tried to use HTTP request-response communication, and it was simple. 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. 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.

What you need my friend is 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. I'd recommend taking advantages of the free Java hosting on offer by CloudBees , just drop in your WAR as you would onto glassfish.

In regards to what your application actually needs to do, I can't advise since you didn't give any specifics :S

...And no, I don't work for Cloudbees, I just think they're awesome

WebView中的NodeJS就是答案

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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