简体   繁体   English

如何使用Smack将XMPP消息从Android发送到GAE

[英]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. 我想使用Smack将XMPP消息从我的Android客户端发送到GAE Server。 I read this post with gmail settings and got the idea of how it should be done. 我读了这篇有关gmail设置的文章 ,并了解了应该如何做。 But I don't how to setup the host and serviceName for my google app engine account. 但是我不为我的Google App Engine帐户设置hostserviceName

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. XMPP可以在几种不同的传输机制上工作。

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 GAE在HTTP上工作,因此您的XMPP客户端可能必须支持BOSH(HTTP上的XMPP),这是规范: 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 然后,您将使用GAE XMPP文档中所述的URL和XMPP地址: 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. 我还没有看到任何文档为GAE XMPP指定端口号,我怀疑它不受支持,因此您将无法通过套接字进行连接。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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