Android app, open connection to to mobile devices - android

what is the best way to create a two way constant communication between a server and an android app?
When I say constant communication, I mean client asking server for data or server constantly pushing data to clients.
From what I saw, I can't use websockets since they are designer for server/browser setups. Is that right? If so, what is the alternative?
Is there free frameworks to work with this in Android?
What I am trying to do is an application that works like a chatting but for multiple people. So they all will get in one "room or channel" on their devices, and then interact with each other, in a way handdled by the server.
Thanks!

As far as I know , one possible way is using a web service where the client can connect to the server , if the web service is RESTFul there are many libraries to access it , one of them is the apache HTTPClient , for the server pushing the only way I know is C2DM for pushing data to clients.

For continuously-open data connection, you may use Sockets. But you should also consider the fact that an always-open connection will drain your battery quickly too. For more details, read this and this

You may want to look at AutobahnAndroid:
https://github.com/tavendo/AutobahnAndroid
which provides native Android/Java WebSocket client framework (plus WAMP = PubSub/RPC over WebSocket .. http://wamp.ws).
This is fully interoperable with WebSocket servers that server browser clients.
The AutobahnXX libraries (where XX = Python, JS, Android) are Open-Source (Apache 2.0). We (Tavendo) are offering a commercial virtual appliance based on Autobahn: http://autobahn.ws
Disclaimer: I am author of Autobahn and work for Tavendo.

But keeping the connection running on the background on iOS and Android devices does drain the battery, for people who have this issue, I suggest using push notifications when the app is not on the foreground.

From what I saw, I can't use websockets since they are designer for
server/browser setups. Is that right? If so, what is the alternative?
Websocket is an IETF/W3C protocol, so it is not confined to a specific client platform. You can use Android websocket to get a two-way communication between Android and server side. For Android websocket client, I recommend using AndroidAsync. It has all websocket API that you need to establish the communication link and exchange data between Android and the server.

Related

Which transport will be used by SignalR between android app and IIS server that supported Websocket?

I want to write an android application and I want to know if SignalR use websocket or something else for communicating between server and client, before I do that.
Anybody know?
By default, SignalR will try to work with web sockets, if they are not available in the underlying platform, it will fall back to SSE, and then to long polling.
Xamarin/Mono current implementation has some issues with web sockets, even though SignalR supports it, so web sockets will not be available.
If your app is made with Xamarin (as you tagged your question), the best protocol you will get is SSE (server sent events). But in my experience (I´ve got an app working with it) this protocol is fast and stable enough for most use cases.
From the signalR webpage
SignalR uses the new WebSocket transport where available, and falls
back to older transports where necessary.
From the Xamarin forums and youtube, It seems people have successfully implemented websocket transport with SignalR on Android
What else can I use?
Socket.IO for an HTML5 application(With NodeIIS),GCM or Firebase like push notifications for native on any webserver

Mobile live synchronization (eg Trello): sockets?

I was wondering how live synchronization mechanisms such as the one used by Trello work.
For example when I move a card from the website, the board is immediately refreshed on the iPhone too. As Push Notifications are not reliable, I suppose a sort of open connection/socket stream is used under the hood.
socket.io quotes Trello among its users: does anyone have any reference about Trello's mobile implementation?
Thanks,
DAN
Trello uses a combination of WebSockets and polling to perform instant updates. Most clients use WebSockets all the time; the few that don't support WebSockets use short HTTP polling instead. It also uses a single HTTP poll to "catch up" after losing a WebSocket connection and reconnecting.
The iOS and Android apps connect using socket.io clients that are locked down to only the WebSocket transport. The web client uses raw WebSockets. On the backend, socket.io is used only to support the handshake and protocol expected by the iOS/Android apps; all of the pubsub/message routing is custom.
I've no excact documentation about Trello but some ideas:
You could use Wireshark, Charles or Fiddler to monitor the network traffic between your iDevice and Trello.
Socket.io is a very nice thing and could be used with iOS (see here). It should be possible to live update a view with socket.io

Is there a way to implement GCM (or CCS) with a server using c++?

I'm working on an App that I've made for both iOS and Android. On the iOS side, I use a constant TCP connection and JSON messages for the push notifications. I want to do the same thing for the android version, however I'm not sure if it's possible. I think using the Cloud Connection Server http://developer.android.com/google/gcm/ccs.html is the way to go, however it only shows samples for Java and Python. Is it possible to use this in c++?
You can choose whatever programming language to desire to implement the server side. The question is whether you can find an easy to use XMPP C++ library for connecting to the Cloud Connection Server.
I assume it will be easier to find an HTTP C++ library for sending HTTP requests to the GCM HTTP Connection Server. If you are not planning to use the upstream functionality (device to cloud), you don't need to go though the trouble of implementing/using the XMPP protocol.

Realtime P2P communication between mobile devices

I am building a mobile device that needs to send realtime information to other devices. I have considered XMPP but I do not have a server, so the communication must be only between the devices.
Is there a way to communicate using XMPP between mobile devices without a server (Or using the mobile devices as servers)?
Is Sockets a good idea ? i.e. Having a ServerSocket and client Socket and communicating this way.
Is there a smarter way? I have heard of jWebSocket but I dont really know how it works or if it's worth it.
EDIT
The process is as follows:
I'm using Parse as a server/backend http://parse.com
When the user runs the app, a user list is retrieved from the parse server
The user then has (Could have) the ip of other clients and then attempt to communicate with them.
Problems
1. Parse does not support a XMPP server or other type of servers
You might look at using an IRC client library like http://jerklib.wikia.com/wiki/JerkLib_Wiki. This way you can use a public IRC server to communicate with your other devices...
I've not used it, but I did bookmark it for further reading because I thought it a novel concept ...
I hope it helps...

What's the best way to implement an application server for smartphone app?

I intend to write a multi platform smartphone app (currently only I-phone and android).
Which has to send and recieve information from a web server I intend to create.
The web server will do all the algorithms, and handles also DB connection.
My question, is how is this best accomplished, which kind of web-server technology fit best the scenario, and supports connections from various devices.
Basically, I thought about implementing a simple TCP/IP protocol, making the app (on the phone) the client, and server on the web on the other side. however, I want to deploy the application to an application server (maybe google app, JBOSS, etc.) and I don't want to be stopped by various firewalls.
does anyone has an idea ?
edit: few things are certain, the application server will be written in java, and db will be mysql.
This is a very broad question and any suggestion about which backend technology to use will depend on your language preferences, your other requirements, etc.
For starters, I'd suggest JSON over HTTP as a transport mechanism: it's easy to parse on both client and server-side, and it's directly usable in Javascript should the need arise. XML is another choice, but it can be annoying to parse.
JSON-over-HTTP (or XML) will be completely device agnostic and won't have the firewall/proxy problems you'll run into trying to do a custom-implemented TCP-based protocol.
For the backend, may folks use MySQL or Postgres for their database, and connect to it from Java, C#, Ruby, PHP, or other server-side languages. Use what you're comfortable with or what you want to learn next.
Why not write the server-side as a regular web application - in whatever technology you like (php, asp.net, java)? This way you can deploy the app on any web server and your client apps on the phones would simply establish a connection to an HTTP server. Normally, firewalls would not be a problem in such situation.
I have used this setup for my apps (both android and iphone) - connecting to a web server app written in php with postgres back-end.

Categories

Resources