简体   繁体   中英

Using XMPP as a push server?

I've been running around in circles the past few days trying to figure out a good solution for my problem. The main key here is that this is for an iOS application. What I want is to quickly communicate from one device to another device updates. So if user 1 performs an action, I want to, in real time, tell user 2 that user 1 has performed this action.

I don't want to use Apple Push Notifications for various reasons. So that's out of the question. I looked into services like Pusher and PubNub, but those are far too expensive (and only allow a ridiculously low number of concurrent connections, ~2500). I also looked into Google App Engine's Channel API, but it works through Javascript, and would have to be implemented using shady techniques on iOS. And honestly I'd rather not use that.

So now I'm looking into XMPP in Google App Engine. It seems like it would do what I want, but I'm not sure if I'm understanding the whole picture. Couldn't I accomplish what I wanted using XMPP messages, that is when user 1 performs an action, I can notify user 2 quickly with a JSON message?

The main key here is that I would have to perform user registration for XMPP behind the scenes, using the user's unique ID. Is this possible, to automatically and without user intervention create a Jabber ID like user-unique-id@my-app-engine-domain.com?

Overall, is this a feasible solution? What am I missing? What are some exceptions?

What you have described all sounds fairly easily doable with XMPP.

Just a couple of points.

  • You do realize, of course, it is XML based, so your JSON messages would be embedded within XML stanzas, with appropriate escaping when necessary.
  • Your user registration would be determined by the server implementation, but I believe most will allow custom authentication hooks (like LDAP). So having an external registration mechanism shouldn't be a problem and is a fairly common approach.
  • Since you are using ios, you should be looking at XMPPFramework as your XMPP library.
  • Depending on your use case, you may want to look at XMPP pubsub as well for your updates, depending on how many other devices are supposed to get the message when one makes a change. I have used this approach and it works well for real time client to client updates.

AppEngine supports XMPP only as client: it can send and receive messages. The key here is if you look at the docs for sending XMPP message , that every client needs to have it's own address (JID) which is not provided by GAE.

So to support your situation, you would need to have an external XMPP server, where every client gets it's own JID and then you can send XMPP messages to them.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM