Creating Server for a mobile multiplayer game - java

I have to build a server to which I make requests using Unity for a mobile game.
I was advised to stay away from using REST for the server.
I want to be able to, in the client, make GET and POST requests via endpoints like "/players".
My question here is: which programming language and programs do you recommend me to start with to build a server to which clients can communicate with, in this case?

I've been using NodeJS to write servers for my programs and I've found it really good for a couple of reasons:
1) It is easy to understand the syntax (JS) if you've been using UnityScript or C# in the past.
2) There is a free download from the Asset Store that helps you parse and send data from a NodeJS server.

Related

Is it possible to use Python backend and a Android/Native application as Front end

I am handling my second year project which includes some machine learning backend along with a Mobile application front end.In simple terms i am creating
a androing/react native application which would take an input from the user and prosses in a backend development which includes python for some machine learning.
My question is, is it possible to connect these 2 together. I have gone through some stuff altho i am not very clear on how to create a connection on this.
Also some opinions on either i should go with android or react native or any other language to go on python or not would be very useful.
Thank you
Yes, it is possible.
For example, you can use Python as backend (server), with some exposed HTTP "interface", then make an Android application that communicates with these Python backend with HTTP request / response.
Or, if you are making a serverless application, you can make this Python backend as a .so library or using SL4A then call them in your Android application.
Yes. you can develop a python web service (REST OR SOAP) and use this for the backend for your application.
also, if you develop a service application (server-client) you must develop a service with python (or any languages) in your server after that connect your mobile application (reactjs, android studio, swift, ...) to this server.

Is it good connect to servlet server from Java, without website?

Several days I didn't learned more about Java server development. I can make a small web-server with WebSocket and Servlet, and Hibernate, like a chat or AuthService. But I'm absolute zero in front-end, and just can't use my knowledge. So, when I found how to use my new skill, I realized what I can made Android app instead of website (because I have experience). For example, I have servlets like
/auth/signin
/auth/signup
Is it a good idea make GET and POST query, from Java code, using Retrofit, for example, or not? Given that I dont have a website, only servlet, on
domain:port/auth/
I just don't know how to organize my architecture. It must be simple client-server, client = android.
Questions: Will it be a good decision to use it for client-side? Or if I don't need in website, must I use only socket connection with TCP? And if I can, how my server URL will looks like?(ip:port/ or domain:port/ or domain/)

Spring webapp: sending notifications to java and android clients

I recently started developing my first web application with Spring and I'm stuck with a question I could not really find an answer to. What I have is a simple Spring MVC application running in tomcat which provides data in form of JSON, XML or binary via REST. This service is consumed by two clients I developed, a simple Java desktop application and an Android app. So far the clients only got information about new data by polling.
What I want now, is a way for the server to send notifications/messages to the clients when new data is available. For the Android client it would be good if the notifications could received anytime, not only when the app is currently open of course. I found lots of information for JavaScript client code but very little really useful, up-to date input about what the options for java and android clients are.
It would be really great if someone could give me some idea what would be the best way to achieve what I want (ideally something which integrates well with Spring on the server side), what protocols/libraries/frameworks to use, maybe even point me to some example or tutorial, how to implement this on server and client side.
Thanks in advance for any input.
For android or mobile devices, Google Cloud Messaging is the preferred way of sending messages to applications running on devices.
Example : spring gcm server side project and a sample tutorial.
For desktop apps, either poll regularly the server or run something in background like crontab or active-mq to check the messages and start the desktop app.
WebSockets are the best solution. check the implementation in java in the server side

Android Client-Server App & Web Services

I have a website that I'm wanting to create a Java application for, and while I don't have any experience creating android applications I have a decent amount of Java experience and feel like I should be able to complete this task over some time. I'll be making use of the Java.IO package for client-side networking (On the application) and hosting a server using Java. This server application will have access to all of the same databases as the website through JDBC. (I'll be hosting it all on the same server.)
My question is how to go about handling connections on the android platform, currently I verify a dynamically generated salt with the database salt on every page refresh to prevent session theft. I also make sure that the encrypted password and the user-name stored in the session match.
I could theoretically just create a standard server application, using NIO and avoding the whole thread-per-client scenario. The problem is that my website has quite a bit of traffic, and I know the application will too. So I'm running into issues on how to handle it.
If I use a keep-alive TCP connection and store the users basic information in a class data structure (Psuedo example):
class User {
int id;
}
Considering all information will be polled from a database and everything is relative to the id of an account, there's no reason to store any excess data into the User class, correct? Just a quick simple lookup tied to the connection to only get data relavent to yourself.
Should I avoid the use of TCP networking for this? What do you guys think.
On the server side, create REST web services that invoke CRUD operations on the server database, and return the responses to the client as a JSONObject or JSONArray. Android has internal support for JSON parsing, and you can use the Volley library to call the web services. Volley is a pretty abstract, high-level HTTP library that makes it very easy to make REST web service calls. TCP connections are quite low-level and are not generally used in client-server Android apps. See the Transmitting Network Data tutorial for more on this.

Connecting Android and java EE server

I am making a game. The client runs in android. It is multiplayer and I want to check as much logic as possible on the server. I am interested how to connect the android client to the pure-java backend. I dont want to deal with the pure sockets as long as it creates a lot of programming overhead. Something like EJB would be perfect, but as long as can see, there is no rmi package in Android or anything. So the only way is connecting it throught Sockets or URL-objects to the REST-service (Could connect with URL to SOAP-based service - but its too complicated to do by hand). Serialization does not work between android and java. What is the best way to connect an Android app in a multiplayer game to the server (better java EE EJB`s or something)? Is there a way except pure XML?
You can use JAX-RS to build a RESTful Webservice, and you can use JSON as the payload. Jersey is a reference implementation, and is a good one. There is JSON support as well.

Categories

Resources