Android client to connect with websocket server using Spring - android

I want to send and receive messages (e.g. via STOMP) from/to my server using Spring.
On the server-side I got following code from the Spring Documentation.
Is there a working android client (with code sample) how to communicate with the server? My target is to connect devices to each other via Internet to make a real-time game. By the way, are there other good approaches to get it started except via websockets?

Another approaches:
Android cloud messaging
Socket IO
XMPP
Websocket libraries:
AndroidAsync
android-websockets
Java-WebSocket
and many more.

The code is incomplete, there's no spring boot stomp configuration and you don't specify how you persist the object response.
I'm working on an Android stomp over WebSocket client. I suggest you check what the client the receive and how it payload string is converted into the object.
My project is still a work in progress, but it could be useful, I hope.
spring boot backend
android client

Related

How to use ejabberd for chat app passing server through API layer

Present Setup
I am trying to build a WhatsApp like chatting app on Android.
In the backend hosted on cloud, I have setup an Ejabberd Server.
Now using smack library on Android, I can connect and message other users via Ejabberd server I setup on my cloud.
Context
This works fine for now, but later I might want to move to MQTT based custom solution for chat replacing Ejabberd and that will force all my app users to compulsorily update their App, since app right now has in its source code stored URL of Ejabberd Server and directly communicates to it.
To solve this problem, I am trying to create a layer of API endpoints so that all communication happens from client phone to ejabberd server via API layer. So tomorrow if I replace Ejabberd server with custom MQTT solution (for scale), then I won't need my app users to update app, since API endpoints have same URL, and I can simply change code behind my API layer, thus keeping me free of depending on Ejabberd forever.
TLDR : Problem I am facing
I am not getting any resource on how to create API layer instead of letting client phones directly communicate with Ejabberd Server. Problem is as per XMPP protocol, client & Ejabberd server directly establish a persistant connection, so how do I put my API layer in between? Its been weeks of headbanging by now and I am stuck.
You can't really put your API Layer between this because XMPP is not publish/subscribe like pubsub.... and something HTTP API is also bad for chat because the client has to request everything and the server can't push anything. I would recommend you to stay with XMPP because it's made to scale very well.

develope websocket client/server on android platform by use of netty

I try to create a simple client/server app, based on web-socket protocol on Android with Netty 4.0.23 final. I saw the example codes and wrote My App. After complimenting them, I ran each of them(Client and server) on separate AVDs, and redirected the associate ports of these AVDS, To connect them to each other, But the client couldn't connect to the server. I traced the client program, and saw that it cann't initiate a proper instance of DefaultHttpHeaders.
Can any body direct me to solve this problem.
The client app can be achieved from [here].
The server app can be achieved from [here].

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.

Android/iOS client consumes WCF Duplex service

I am trying to build a server/web service which provides APIs to Android/iOS client. I am using WCF service and clients can send request to server successfully. Now, I am going to make server enable to ping client to notify that there some changes in server and client need to synchronize data.
The question is: Is it possible to enable my server to ping client (Android/iOS), I knew that it is possible for Windows client by using wsDualHttpBinding but I am not sure about iOS and Android client. Anyone can help me to make it clear? Any solution is appreciated.
I don't think you can do it. For start, while wsDualHttpBinding is intended to be interoperable I don't beleive in practice it is supported by any otehr framework than WCF. Then wsDualHttpBinding uses a client callback url that the server needs to contact. This url is not going to be accessible on a phone. You should use websockets, long polling or some proprietary push mechanism of the device os.

Android app, open connection to to mobile devices

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.

Categories

Resources