XMPP chat client in Windows Phone 7.5

2020-02-10 00:54发布

问题:

Where to begin? to create XMPP chat client in Windows Phone 7.5 as its not possible to use Jabber-Net library. This library is for .Net Windows application.I have no cues. Any open source library like agsXMPP(supports .Net compack framework but not open source).Could anybody help me please?

回答1:

1) agsXMPP is Open Source licensed under the GPL. You can port it pretty easy to Wndows Phone.

2) The major problem is the platform itself. XMPP and most other IM services require a persistent socket connection. There are sockets in Mango now, but whenever your app goes in the background the socket gets disconnected and you are not able to receive any data over XMPP. When your app is in the background then the only way to receive data are the Microsoft Push services. As firebellys pointed out this is the reason why there are not many IM apps in the Marketplace. You either use push only and convert XMPP <==> Push on your webservice, or you use a combination of both and use Push only to wake up your app and then reconnect with sockets.



回答2:

The short answer is no. Microsoft tried really hard to try and get you to use async networking as much as possible. The best answer is to build a web service (azure or whatever you prefer) that manages the chats with background events checking for updates. The harder answer is to hack at jabber-net to use sockets from the newer wp7 SDK. Sockets were not available in 7, but were in 7.5 Mango.

This is why you don't see a lot of IM clients on the market place (and many that do exist aren't very good), the work around for lack of true realtime networking on the phone prove to be more trouble than it's worth. You often end up writing an completely new chat state service in the cloud or hosted on a server, to deal with it.



回答3:

This is a excerpt from an MSDN Page for Windows Phone 8.1

There are two primary features that allow an app to receive incoming network packets when the app is in the background,

1.Raw push notifications that are received by the system and result in running a background task in the app. Using this feature, the app receives the raw data from Windows Push Notification Service (WNS). The contents of this data must be understood by the app. The app must register with WNS to receive the raw push notification.

2.Network triggers using ControlChannelTrigger that run a background task to receive incoming network data or send network keep-alive packets. Note ControlChannelTrigger is not supported on Windows Phone.

So, Alex's answer is still the only way to go about this



回答4:

One way to keep a connection alive would be with a background audio streaming agent, which is obviously an abuse of Microsofts developing guidelines and thus your app won't make it on the market place -- unless, of course, you provide text-to-speech support in the client. ;)