How to - Flex client side and Java as Server side - java

Since I'm developing a multiplayer card game for Facebook using Flex as client side and Java SE as server side, I wanted to know how do I actually make the connection between Flex and Java? the server and client should be able to send each other data(cards,movement,room information etc...) across and I wonder what's the easiest way to do it without complicating it.
Any idea how to do? where to read about it ? I know JAVA but I find JavaEE hard to understand.
Any help will be appreciated, thanks.

You can pay Adobe a lot of money and use their enterprise products.
Alternatively, you can use the open source BlazeDS, which allows you to communicate with plain text (direct HTTP) or using the binary AMF protocol with object serialization.
Also, if you are thinking about using JSON, as3corelib will help you on the Flex side.

using SOAP as it is built into Flex already seems the easiest way to got...
For some information/example see
http://livedocs.adobe.com/flex/3/html/help.html?content=data_access_3.html
http://www.blackpepper.co.uk/black-pepper-blog/How-to-use-SOAP-web-services-with-Flex.html
http://www.blackpepper.co.uk/black-pepper-blog/How-to-use-SOAP-web-services-with-Java-and-Flex-Part-2-of-2.html

Related

Sending and receiving data from an Android application to a web hosted Java application

I've been looking around all morning, and can't seem to figure this one out. I know it's not as complicated as I think it is, and all I need is just some pointers to the right direction.
I have an Android application that takes some user input, sends it to a Java application over the web, and then receives some output based on the input.
My Android and Java applications are ready, but how do I go about sending and receiving the data over the web? I understand that I'll be sending and receiving HTTP requests, but my problem is where I'll be sending them and receiving them from. Do I host my Java application on a Servlet like Tomcat, or do I use something like OpenShift to host my application for me?
I have no trouble with sending some HTTP request from my Android application to the web and receiving some output back, but my problem is that my web service needs to use a Java library to process the input and generate the output. I'm just not sure how I'm supposed to get this data to and from this Java library that needs to be hosted on the web.
I hope my question makes any sense.
EDIT: Perhaps I wasn't clear with what exactly I need help with. I do realize that the architecture I use doesn't really make any difference, but the problem I have is with how I'm supposed to use this architecture.
Let's say I have a registered domain name that I can easily send to and receive data from using my Android application - no trouble with that. But how am I supposed to integrate my Java library with this server? Do I just create an applet and put it on my server? Does my web host even allow Java applets to run?
I guess my question is how I'm supposed to get through the "barrier" between my HTTP request / transport layer protocol and my Java application.
Server architecture usually does not matter. You can use Java, NodeJs, Rails, Python, .NET, etc. You just need an endpoint that accepts a HTTP POST/PUT/GET/DELETE/PATCH verb.
This is more a question of "how do I set up a server to accept input" and its a very large topic in itself. I would advise you look at PAAS solutions like:
Parse.com
Kinvey.com
You can use their tools to build a solution fairly quickly. If you need something custom you'll need to build your backend in the language of choice and host it online via AWS, Google Cloud, Heroku, a VPS or something similar.

How to send a Serialized object from a server to an Android App

I need to send an object built in server to my Android app. I'm looking for the best way to do that. I dunno if the best choice is just JSP with binary output, or maybe RMI or just sockets. Google Cloud Messaging should be my choice, but It seems Im needing a supporting server for this technologie.
Any suggestion?
Thank you.

Java for android Shared Database over LAN

Hello i've been coding an app (client/server) over my LAN in Visual Studio 2012 using this http://www.codeproject.com/Articles/155282/A-Complete-TCP-Server-Client-Communication-and-RMI#ScsServerside as the base for my communication between the client and the server.
Now i started looking over on android development and eclipse and i was wondering if there was something similar to this framework on java? if not maybe someone could point me out on a way of calling methods over LAN and if possible without using the hole webservice on tomcat thing :p i cant really understand how that is working and since i intend to sell the app i dont know what implications using those components brings.. Whereas this framework i was working on didn't need anything.. it simply runs the application (server) with a service on the ipaddress of the machine on a open port ant that it.. Any help would be gratefull!
Adding some more information to your question would be useful. For example: which kind of call are you accepting on your server? Or, in other terms, what protocol are you using? Just plain old HTTP? RESTful HTTP? FTP? SSH? What?
Anyway, most likely you do not need any third-party framework to create your own Android client. Android and Java already supply you with a HTTP library and a HTTP client that can be used to communicate with a HTTP server. Just browse the docu.
If you have to use a different protocol, most likely you can find a Java client/library that you can use in your project. Java has the largest library of ready-to-use components so it is usually quite easy to find something that can solve your problem.

What to I need to do to on my server to communicate with an Android app?

I am currently writing and Android app, and I need to do some stuff with a server. Actually I just don't know where to begin, since I don't know very much about server side.
My Android app will send Java objects and images to my server, so what do I need to write or use on my server ? Is it possible to write Java code instead of PHP on the server side ?
Could you please give me the steps to prepare my server ?
Is it possible to write Java code instead of PHP on the server side ?
You can use any programming language you like for server side programming. This question provides some useful information on various Java based approaches using the HTTP protocol.
will send Java objects
You will need to serialise them to a data format. JSON and XML are popular for transmitting structured data across HTTP.
and images to my server
HTTP allows the transmission of files and Java can construct the request.
I see that you just want to communicate between the server and client(Android). I would recommend considering REST style web service for your server, where you can use either JSON (recommended) or XML format.
How to implement REST in a web application?

Java game server with Android client

I'm about to start a game project. It will be a network game with client-server architecture with Java server and a Web and Android clients. Impact is on low bandwidth (for use on mobile devices) and fast response. What technologies / libraries are out there for client-server communication? I am somehow experienced in web applications (GWT/Vaadin and servlets) but have no clue what to use when implementing a game server, mainly for the communication.
I am aware that I could use Java sockets with Object serialization or maybe JSON to pass the data from client to server, but I don't know how efficient in terms of bandwidth these approaches are? Or are there any more suited than these? Just pointing me in the right direction will suffice.
Thanks in advance!
As far as Android client libraries go, there's two main options. The first is just the java.net.* package in which you'll mainly use HttpUrlConnection.
The better option is to use the Apache HTTP package that also comes standard in the Android SDK. It gives you a lot more control / flexibility / verbosity in dealing with network connections.
Here is a decent example of how to use the Apache client libraries. I suggest using these, as the java.net packages are really only suited for the most basic of GET requests.
I suggest using the JSON method, because then you're not stuck having to write a Java servlet backend to deserialize the Java objects. The backend can then change independently of the client.
The main problem is, if you use WebTechnologies, than you can't implement an efficient way to realize the communication from Server to Client ...
Client to Server over HTTP GET works fine, but you must use some kind of Comet to realise the communication from server to client.
Thats why plain old tcp connection over socket would may be the better to communicate with a Client, especially with Android Client.
But implementing it with tcp socket work great with android, but not with a Browser.
My solution: implement the communication via WebSocket.
WebSockets (part of HTML5) is a HTTP extension to enable full duplex communication between client and server.
The most major web browser support WebSocket, like Firefox 4, Chrome 9, Opera 10.7
BUT NOT the Internet Explorer (support planned in IE 10, comming with Windows 8)
And for android, there exists also java libaries to implement the communication and i would excpect, that they work also well with android.
Expample:
http://code.google.com/p/weberknecht/
For the server side: Servlet API 3.0 support that, like Jetty 8
In my opinion WebSocket would save the problem, so you can implement a single server which supports WebSocket and communicate via WebSocket to an Android client as well as with a Browser Client (except Internet Explorer)
It depends on timeframe of your project. If time is enough – try in your hands and compare the technologies related to your purposes.

Categories