I have searched around a little, but I couldn't find a complete answer on this, that's how I am asking. I have a Java Project of a messaging system, having implemented the server logic, using the implementation of the Chord, working as a distributed system.
I also have an Android app project, implemented for the use of the client gui, which I want to connect with my Java project in order to manage the proper requests and responses.
What is the best way to connect these two projects? My Java project is on the Eclipse IDE, and the app on the Android Studio. I know Android Studio uses a set of configurations and libraries, and since everything is Java, the correct way might only be to pass these configurations to Eclipse as well, and copy my android files there. But I am actually new to Java, and specifically the logic and the structure that it follows and I want to be sure of my actions, as I want to avoid going back and forth to this. I hope I gave all the right information, but you need me clarify anything else, just let me know. Btw, everything is local, there is no connection with external servers or any database.
Thank you in advance!
For client requests to the server:
You can use one of the networking libraries for android - Volley/Retrofit for example. It shouldn't matter that your server is on the same computer, you will just need to adapt the url accordingly.
For messages from the server to the client without client requests:
You need Firebase Cloud Messaging.
Related
Over the weekend I set up all the networking for a game I was making. I was basing it off this tutorial: GamesFromScratch.com Basic LibGDX Networking. It said that it only supported TCP but I was okay with that since I could figure something out and there was a bunch of material online on how to make real time games without UDP. After I finished, I tested it on desktop, android and then on HTML5/GWT. Desktop and android worked but GWT didn't. I did some research and found that Gdx.net does not support GWT, the article didn't warn me :/ Basically now I am trying to find an alternative solution that will work with ALL libgdx platforms.
I looked into Websockets with Socket IO. Here are the Java libraries I found for the: Client and Server. The server library says it works well with the client one which is reassuring. It seems like a good solution but I have a few questions:
- Would the client library work on all platforms? It seems that it would work on android and desktop since they don't have to convert to another language but what about GWT and iOS? And not only just work, but also be able to connect to the server using the server library.
- Is there anything I need to watch out for when using websockets?
Thanks.
EDIT: I did a little bit more research and I found Jetty. I looked around and it seems to be GWT compatible, I just need to know if it is also iOS compatible. And could I use Jetty as my server api also?
I did it. I did a lot of research in the past few days and I finally found this post on stackoverflow.com that told me about 2 great libraries including one I could use with the client that supports GWT.
It works great, the only thing is that I will have to use 2 WebSocket libraries for the client, one on html and another for all the other platforms but that's okay, at least it works.
The libraries are: Client and Server.
you can use Kryonet which provide network for PC, Android and iOS(not tested). On this library you can build server side or client side app.
In GWT you have WebSocket and you must use other library to connect with server.
When you start game, you can inject right implementation client for GWT can be example: gwt-websockets and kryonet for other platform.
Next, you must change kryonet default serialization implementation by own, supporting json. In my project i use LibGDX json serialization.
Currently, i don`t have support for gwt but i will work on it in near feature.
Jetty in my opinion is too heavy for client and isn`t simple so much. But witch Spring, you can easy create server service based on REST or http communication.
I'd like to know if someone can guide me in this aspect, as everything I know is that Datanucleus REST API may help into making the contents of my local Google App Engine datastore and the online one the same, but there might be also another way to do that which is easier, as I'm having great difficulties to understand how could might be done via that API. Application has been done in Java so there's no point in trying to develop it into phyton know, it's way too late for that now.
Thanks a lot for your interest.
Edit: Well I actually found some interesting tools here: http://www.appwrench.onpositive.com, but it would be better for my application if I could done by code as it would need to be executed automatically once a day, so if you know of some not too hard way to achieve what I'm telling I'll be grateful if you tell me so, if not I'll just stick with the tools.
I don't know DataNucleus, but you can connect GAE Datastore from local machines using Remote API
you can use Remote API to access a production datastore from an app
running on your local machine. You can also use Remote API to access
the datastore of one App Engine app from a different App Engine app.
With this, you can code an app to synchronize the data
I would like to make an update finder, so to speak. The client application would send a request to the server, get the latest version, and return it to the user in the form of a prompt:
There is a new update, X.x. Would you like to update?
Something of that nature. How would I go about doing this?
Also, if possible, please don't suggest API's unless it is either really necessary or it would be really hard for a beginner to understand. I would like to keep my project working with core Java packages.
Have you looked at Java Web Start?
Updates to a Java Web Start application are automatically downloaded when the application is run standalone from the user's desktop.
http://docs.oracle.com/javase/tutorial/deployment/webstart/
One way to do this easily in Java is to use Java Web Start.
I plan on making an instant messaging app on Android and iOS, where you can chat to other people with the app, along with some custom features.
I’m going to use the XMPP protocol, and make a custom extension for it. I plan on making a Java application running on Amazon Web Services (AWS) so it's scalable.
After researching server options I’ve decided to use Apache Vysper.
However, I’ve never made a proper Java application before, and have never used XMPP, AWS or Vysper – so I’m rather reliant on good documentation :-)
The Apache Vysper project is very new and so the docs are a bit sparse. I was wondering if I was missing something, should I be using the general MINA docs as well? Are there other resources
elsewhere I don’t know about?
“Apache Vysper can run stand-alone or embedded into another
application.”
To be honest I’m just as lost when it comes to working out what to use to make a Java application anyway. Do you know if the AWS Java SDK has everything I need to make an application to use on AWS? And then is it a simple matter of integrating Vysper into this? Or do I need to make a Java application using something such as the Spring framework?
Thanks for taking the time to help me. If you know anything that could clarify the situation I would really appreciate it :-) --and sorry be being a bit useless, but hey, we've all got to start somewhere right ;)
First of all, as the founder of Vysper I apologize that the documentation is lacking completeness.
To answer your question(s).
Most Java applications bring their own ready-to-go start scripts with them.
Vysper is no exception. You get the pre-packaged download here:
http://mina.apache.org/vysper-project/downloads.html
Ok, before running it, you need to have Java installed, whether you're on your own machine, AWS, a server or a virtual machine anywhere else. Get it from Oracle, or use the package management of your Linux distribution. Make sure that after installing Java, you can execute "java -version" on the command line and you are all set.
Then, unpack the Vysper download, change to the bin/ directory and execute "run.sh" or "run.bat", depending on your OS.
Please note that support for Vysper - besides here on StackOverflow - is available on the MINA user mailing list here:
http://mina.apache.org/vysper-project/mailing_lists.html
I really don't know what I'm doing, and have been trying to learn about it, but I figured I would ask for help; I have a java server (essentially the one here: http://www.akira.ruc.dk/~keld/teaching/OOP_f02/Book/chap09/BroadcastEchoServer.java, just playing around with stuff so I can learn about it), and I want to be able to run it on the internet , so with the client applet I wrote that you can embed in a browser, say, you can connect to it from different computers. I really have no idea how to go about it. I downloaded some things (Tomcat, Glassfish), signed up for google app engine, and something I think is similar specifically for Java, but I'm not really sure what I am doing. I am thinking I get j2ee or something? I use a mac and xcode, if that's useful at all.
Thanks in advance
Oh, the client applet is like the one from a java socket tutorial here:
java.sun.com/docs/books/tutorial/networking/sockets/readingWriting.html
If your server is already working locally, what you need to do is to put it in a hosting service.
That way it can be accessible by everyone else.
That server, is an stand alone application ( that is, it doesn't need tomcat or glassfish, and certainly won't run on Google App Engine )
The only thing you need to do, is have it install it in a machine which is accessible from the internet. How to host an application is out of the scope of this site though.