开发者

Android Duplex connection with server

I am trying to create a duplex connection (Chat Application) between android device and the .net Client application. I have implemented it using TCP connection. But because of the some reason I would like to implement an HTTP based duplex connection. The middle tier is a webserver and it is communicating through SOAP based webservice.

When ever client sends a message to the webserver, it should automatically invokes the android application and displays the message. For example, if the webservice getMessage() is empty android app shouldnt do anything but if there is any message fire it and display the message.

I have implemented it with the help of C2DM Push Notification. But I need a nice solution, I need to implement some kind of Listener in Android application which only get invoked if there is some message. When I did some research I found out that, it can be done using asynctask, but even if the getMessage() is empty it will call the onPostExecute() method. I want to control it such a way that, only when message is not empty it should do the onPostExecute() method.

How do I achieve that? Kindly spread some light. (Excuse me开发者_如何学运维 for the terrible english you guyz have ever seen).


On a side note, using C2DM for a chat application is a really bad idea because of the quota that C2DM has. Instead, you should think about setting up an XMPP server and communicating using it. Openfire is a nice solution and the installation is very simple. For the .NET client, you can use AgsXMPP which is a very nice library.

Sorry my answer doesn't really answer your question but it does offer advice on a problem you will encounter in the future.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜