Using Angularjs to send and receive data to/from server - java

I am taking a computer science course, and currently we are working on a project where we have to build a simple game application. I am working on a tic-tac-toe game where there is a client and a server. Players can sign into the client and connect to the server where they can interact with one another by playing the game.
I am curious if I could build an angularjs web app that can send and receive data from the server (coded in java) to be able to see who is logged into the game, send messages to the chat box, as well as disconnect users from the server.
Is this something that is possible? If so, could anyone link me to some reference materials so that I can learn how to do this.
Thank you!

Related

Sending simple text data live from Android client to server

I've seen other posts on streaming live audio and video from an android application to a desktop server, but not yet for simple textual data. Basically, I'm trying to send key values from the android keyboard directly to a desktop server (which is implemented in java) as I type on the client. This would be a simple remote-keyboard sort of application that displays a keyboard on the android device and sends the live key taps to a server, which accesses the PC keyboard via the Robot class. I understand how to send text from the device to a server, but I am stuck on how to make the transfer of the text data to the server instantaneous, as the user types on the device.
I've tried to adapt from the examples for live video/audio streaming, but I couldn't figure out how they worked as I am still very new to client/server programming and programming in general.
Any help would be appreciated. Thank you.

Server to Server Communication with Java

I am currently developing a game, and would like to separate the login server from the game server. While I am experienced with client-server networking, I have never done any work communicating between servers. What are some standard or accepted methods of accomplishing this? My current topology(?) is to have the game client connect to the game server, handle all logging in and authentication, and then start processing game data/packets. What I would like to do, is split the login server and game server into separate entities, such that the client will initially connect to the login server, after proper authentication has been reached, send the client over to the game server and start processing game data.
What would be an acceptable way of handling this?
EDIT: It seems the intention of the question may be unclear. My question is, is there some sort of functionality that would allow server-server communication, OTHER than creating the login server as a client to the game server?
No, There is not. One of the two parties always needs to be listening for connections while the other end connects to it.

comunication between server, JavaFX desktop app and android app

this is a theoric question.
I want to deploy an app, actually 3, that:
-Manage a database (SQLite) from the desktop, in JavaFX, Done!!
-Server/WebApp that sends data(JSON) to several android devices.(¿Grails??)
-Android App to recieve and manage the JSON (and more things).
My doubts are:
-In my desktop app when the user chilck the "Send info to device"
the app must do a call to the service app like http://myserver/receiveJSONtoSend and the server listen the request and send the data to the device? and in the device recieve and do things with the JSON, and when the task are finished send other request to the server and the server comunicate to the desktop app. This is right?
-How the server comunicate with the desktop app? by suscribing like a listener?
Sorry abot my english and my non especific question, if some extra information is needed tell to me please!
Thanks a lot!!!
Since Java is painfully object oriented its often a good idea to use a JavaRMI engine for Java to Java communication.
#mod: I see this as a comment, but can't put it there on my own. Thanks!

What is the established way to request data from an android device

I currently have an small application that I have been using to learn java/android programming. Right now I have a setup were the app on one phone sends a request (via sms) to another phone running the same app. The remote phone receives the request and sends back some info. Next I would like to try this from the web. Is there an established "best" way to to this?
I was thinking I would have a web server send requests to the device via google cloud messaging and then have the device return the data directly to the web server. (Not that I really know how to do any of that just yet).
I see that there is a google cloud messaging return path (send messages from the device to the google cloud server, but it seems very new, do I need something like that? The main thing I want is to be able to ask the phone to do something when I want, not have it poll to see if there is a request, or just periodically update some status.
UPDATE:
Thanks to the answers below for confirming to me that I was on the right track.
I now have some basic functionality.
I started out using this gcm android demo code
https://code.google.com/p/gcm/source/browse/#git%2Fgcm-client%2Fsrc%2Fcom%2Fgoogle%2Fandroid%2Fgcm%2Fdemo%2Fapp%253Fstate%253Dclosed
and this ruby gem
https://github.com/spacialdb/gcm/blob/master/README.md
between the above two I was able to send a message to my phone pretty easily.
To get the round trip working, I setup a very simple rails app on heroku.
I included a modified version of the sample code in the gcm gem in a controller and then used
HttpPatch (needed for rails 4) to send a post/patch from my phone to my web app, the controller then echoes the message back to my phone.
I guess it would be nice to get the two way gcm stuff to work, but I am not sure there are any gems that handle that, and I am not qualified to handle a task like that :)
I would say it's the right call: Google Cloud Messaging for Android
From the site Android Developer:
This could be a lightweight message telling your app there is new data
to be fetched from the server (for instance, a movie uploaded by a
friend), or it could be a message containing up to 4kb of payload data
(so apps like instant messaging can consume the message directly).
In this case you don't want to fetch data from the server but you want to send them.
You can send them in different ways. I would suggest, since you are learning, to try a RESTful solution using one of the implementation of JAX-RS.
As a short and direct answer for beginner : GCM (Google Cloud Messaging) would solve your issue. However, if your app turned out to be something bigger, other more technical and complicated solutions are present too.
see this link.

Connect Two Android Phones with Java Server

Which is the best way to connect 2 android phones in the internet with a Java Server?
I'm making an game form android. At this moment i have the single player working. But now i have two use an Java server to play online games.
Which is the best way to communicate with 2 phones ?
Most difficult action is send information of client1 to the Server and Server redirect this information to client 2.
Anyone can help me?
Regards
You can use either SOAP or REST, using Jax-RS (rest) or Java-WS (SOAP).
http://www.oracle.com/technetwork/java/index-jsp-137004.html
http://docs.oracle.com/javaee/6/tutorial/doc/giepu.html
Here is one way, assuming your game has some turn based interface, and you want to do is have a create game/join game or a create game with user style interface.
When the game starts, connect to the server using one of
the above techniques (soap/rest) to let the server know you are
there.
Then have one client say create a new game. This will tell the
server to create the game.
The other client will tell the server to list games. Then on
the client, choose a game to join. Then tell the server of the game
choice, so that it knows to add you.
The phone that started the game, should poll the server to see if
another user joined the game. Eventually some will join. (there are
other ways to handle this, but polling is very easy to do)
Have all players in the game poll to find out if the game started, then
go, once they have all joined.
There sure isn't a best way to do that. There are some techniques.
But what I would do is to create a long, unclosed http request from both of the clients to the server and then when something happens the clients get responses from the server. This is called Comet, but I never implemented that by myself. There sure is an Android implementation (or just a Java implementation).

Categories