Cross-platform server application to communicate with Android/iOS on WiFi - java

I am working on an application where I need to establish a server on a Windows/Linux/Mac machine which will need to communicate to an Android/iOS device over an existing WiFi network.
I am just in the research phase for now, and though I can find answers for communicating between PC-Android, PC-iOS, Mac-iOS etcetera, I cannot find an answer using which I can do all of it.
The mobile application will be different for both the platforms, of-course, but the server application should ideally be the same, and should be cross-platform.
I should also mention that the server and the clients(mobile-apps) will maintain a 1:n relation, meaning that several Android/iOS devices will be communicating with the server at once.
I need advice on which language/library shall I use for the server which would let the it communicate to both the mobile platforms.
Advice on the libraries I should use for the mobile platforms will also be helpful, though it's not important until I complete the server.
I am just looking for links to helpful resources, though I will be very grateful if you share some code.
I shall also mention, I know Python/Java/C++ which I can use for the server, but you are open to suggest another language which may make the work easier.
EDIT: What I forgot to mention is that, this will be a local server, that is, it needs to communicate with these devices on a LAN (devices on the same wifi network).

If you Know Java for the server side you cab create an application that hosts a RestFull API running on a tomcat server that you call with a local address (such as http://ip_adress:port/appname)
Tomcat can run on Windows, Linux or Mac.
If you need more informations just ask

Related

How to make a local test server for an android app?

I basically need to create a test server, something that I can use locally to perform tasks for my application.
So my android app is basically a search engine, however the search queries will be made on the server and the results then fetched from the server on the mobile device as JSON objects.
Is there any way to replicate this functionality locally? I would just like to set up a server, include the Spring framework, the Google Custom Search API and develop it all in Java, then ship it to a live server directly when it's finished. (Most presumably a free tier Amazon AWS server, either EC2 or Lambda, not sure what the difference is).
Not quite sure where or how to get started so any help is appreciated, thank you!
p.s. I may try dabbling in some machine learning at a later date, but I don't know if this will affect anything, this will most likely be after I've got a live server up and running.
EDIT: Sorry, so how would I fetch data from a local server from my mobile device? Do I need special software? Do I need to configure a local server? How can my mobile device fetch data from a second project when its being run on the first?
My app will fetch data from a server, so how can I create a dummy server, for it to fetch data from? Will I need to create a fully functioning online server, or can this just be done through creating a local server of some sort and then simply plugging my android device in and running the code? I have absolutely no idea how to test it without putting it online.
You can run a local installation of Tomcat server on your own machine.
Access the server by visiting "http://localhost:8080/" (or) http://127.0.0.1:8080". You can basically listening to your own local machine / host's 8080 port. Sometimes, it could be port 80 instead of 8080.
Please explore on how to host a Spring or Java application on a local server.
A good starting point would be to learn J2EE or Enterprise Java. You can configure Databases from your local installation.
If you opt for PHP as your language on server side, there is a pre-defined package called WAMP (for Windows), LAMP (for Linux), MAMP (for MAC) and XAMPP.
The above package are nothing but a package which contains a Server, Database and a Server side language usually PHP, if needed Python or Perl.
Please explain in which step you are getting issues so that anyone can help you exactly.

Need to call from jxfs client to jxfs server

I am very new to jxfs things. I have a requirement to call jxfs server which is in cloud server from the jxfs client which is in ATM environment.. How can i call?.. I need to call this one through the Jxfs RMI concept. It would be appreciated one if any example code is available. If atleast you are having code for calling from jxfs server to jxfs client, please post it.
Thanks in advance guys.
One of the interesting things about J/XFS and remote device access (based on RMI) is that it is just matter of configuration.
You need to configure a J/XFS repository in order to handle a remote device (basically set 'remoteAccess' to true).
Then accessing these devices from the programming point of view is just the same as they were local devices.
Architecture is explained here: ftp://ftp.cencenelec.eu/CWA/CEN/WS-J-XFS/cwa14923/cwa14923-01-2004-May.pdf
Details, when programming may differ depending on the J/XFS implementation you are using.
Trying to answer your question below:
Whenever you want to access a device remotely in J/XFS, RMI is used. You need to make the following setup:
On a server (should be accessible) you need to start a JxfsServer. The JxfsServer will use a Read.repository
whith all the ATM's and devices configured on them as workstations, with the right IP addresses.
On the ATM, you need to install:
J/XFS libs
J/XFS device services for the devices on the ATM
Setup the DSstarter:
Will use the SpecificDeviceManagerRMI connecting to the JxfsServer you started before.
On your server (cloud) wherever you are going to use the J/XFS client you can get the remote controls by performing
the J/XFS initialization as follows:
jxfsDM_ = JxfsDeviceManager.getReference();
jxfsDM_.initialize("com.jxfs.forum.communication.rmi.SpecificDeviceManagerRMI,<atmWorkstation>,AppTest,2006;<jxfsserverhostname>,");
Then you can get the remote device controls with getDevice(...), and start using them as if they were local devices.
Please, note that handling RMI ports can be tricky, specially in a secured environment as ATM network. Make sure all the ports you need are open.

Uniquely connect an android application to a java applet on pc

I want to connect my android application to an applet which is running on my pc on Google chrome on Wi-fi.. where my phone works as a wi-fi hotspot and pc as the connected device. I want the connection to work uniquely as I want commands to be passed from my application to the specific applet, on the execution of which my applet does specific tasks. Please tell me the APIs which I can look in both Java and Android or the technology I have to use to make it work..
You need to use any program, such as wamp server, to make your computer to be a localserver. It will install PHP 5, MySQL and Apache. In other hand, you will also need a little bit of knowledge in Php language to create you own web services.
Another thing you need to be aware is that to handle you connection between server and device (and by this I mean which IP you are going to use) you will have a little headache; but first things first..break your problem in little parts thus will be easier to solve them.
I recommend this tutorial.
I think the simple way to connect these two softwares is using UDP.
It is fast, it is easy to program but it is generally unreliable according to TCP. But it is already local network. I dont think that is a case you need to take care in your local wifi network.
So take a look at this tutorial http://tutorials.jenkov.com/java-networking/udp-datagram-sockets.html
There are other ways like https://www.alljoyn.org/. It has more functinality but more complicated.
You must install Server on your PC(Apache httpd or apache tomcat or other based on your interest). A server listens to request from clients. When your mobile is connected to your pc(doesn't matter wire or wireless), you can make a request to an url(say, localhost:8080/welcome) from your app.
Create an applet and connect it with your web application(in the server) using java.net.URL and java.net.URLConnection.
On performing some operation on the client, call the url of the server application and forward the response to the applet.

Android game, local and online, with clients that can be used as servers, without duplicating code

I want to write an application for Android, a card game that can be played both locally and online. That means we have clients (Android phones), and servers. Ideally, an Android phone should be able to be used as a server and host a game (and play it at the same time). I don't want to duplicate code between the server and the client.
Here is what I had in mind: having the application contain the server part, that would be runnable indepently by the application itself, or without the application (on a computer).
In a local game, a thread would be run for the server, and another one for the client (which communicates with the local server through localhost). In an online game, a distant server is running, and the local client communicates with it through the network.
My questions are:
Will my application be able to communicate with a thread that comes from itself, through localhost?
Can I have the entire application as the server? On the phone, it would run the server thread, then the client thread (do I need one?). On the distant server (desktop computer), I would run only the server thread, without all the Android stuff.
Do you have an other idea?
I hope I have been clear enough for you to understand the problem.
Thanking you in advance.
Yes, your app could communicate with itself through TCP sockets, that shouldn't be a problem. I'd advise you to take a look at putting most of the server functionality into a jar file, then you would have an Android APK and potentially a separate Java frontend for your desktop. You will likely need to have a little hosting code that's specific to each platform. It might make sense to put your server in an Android Service for example if you want to be able to host in the background.

Java Network Events

I am creating a java mobile application and I want to be aware as to when the device obtain an IP address to then be able to send messages to a backend system.
Do any API exists? I guess if an API existed it would have to use system dependant calls thru JNI?
Thank you,
Julien.
OK, I'm not 100% sure I understand what you are trying to do but here are a few things that could prove useful:
stackoverflow has tags for J2ME and javaME, the mobile versions of Java.
Theorically, installing a MIDlet that declares a static PushRegistry socket connection could force the device to always have an IP address. That would obviously depend on how the Pushregistry spec was interpreted by the VM provider.
There is no standard JNI support for mobile Java virtual machines.
A mobile Java application may be automatically paused when it is backgrounded so I'm not convinced you shouldn't just use the GCF API to open a client socket connection to your back-end system. It is presumably only needed when the MIDlet is in the foreground.

Categories

Resources