简体   繁体   中英

How to send a XMPP message from Android to GAE using Smack

I want to send XMPP message from my android client to GAE Server using Smack. I read this post with gmail settings and got the idea of how it should be done. But I don't how to setup the host and serviceName for my google app engine account.

String host = "talk.google.com";
int port = 5222;
String serviceName gmail.com;

ConnectionConfiguration connConfig = new ConnectionConfiguration(host ,port , serviceName);

XMPPConnection connection = new XMPPConnection(connConfig);
connection.connect();

Message msg = new Message(to, Message.Type.chat);
msg.setBody(text);
connection.sendPacket(msg);

XMPP can work over a few different transport mechanisms.

GAE works on HTTP, so your XMPP client will probably have to support BOSH (XMPP over HTTP) Here's the spec: http://xmpp.org/extensions/xep-0124.html

You would then use the URLs and XMPP addresses described in the GAE XMPP docs: https://developers.google.com/appengine/docs/java/xmpp/overview

I haven't seen any documentation specifying a port # for GAE XMPP, I suspect it's not supported, so you won't be able to connect over sockets.

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