请问您们使用什么集成技术来将外部组件实现到现有的XMPP服务器(例如ejabberd或OpenFire)中?是直接通过向另一个user@externaldomain发送XMPP消息,还是使用像urlfetch这样的机制?
请问您们使用什么集成技术来将外部组件实现到现有的XMPP服务器(例如ejabberd或OpenFire)中?是直接通过向另一个user@externaldomain发送XMPP消息,还是使用像urlfetch这样的机制?
谷歌应用引擎(Gae)支持XMPP,就像客户端一样。
通过XMPP Gae JAVA客户端功能,您可以:
发送消息
JID jid = new JID("youraccount@jabber.org");
Message msg = new MessageBuilder()
.withRecipientJids(jid)
.withBody("Hello i'm a fancy GAE app, how are you?")
.build();
XMPPService xmpp = XMPPServiceFactory.getXMPPService();
if (xmpp.getPresence(jid).isAvailable()) {
SendResponse status = xmpp.sendMessage(msg);
}
接收消息
public class XMPPReceiverServlet extends HttpServlet {
public void doPost(HttpServletRequest req, HttpServletResponse res)
throws IOException {
XMPPService xmpp = XMPPServiceFactory.getXMPPService();
Message message = xmpp.parseMessage(req);
JID fromJid = message.getFromJid();
String body = message.getBody();
//Save to Big Table
}
}
请记住,JIDs可以是 yourappid@appspot.com 或 foo@yourappid.appspotchat.com ,因为Google域名尚未受支持。
例如,您可以制作一个玩具Gae应用程序,其中包含:
要测试您的应用程序:
如果您拥有自己的XMPP服务器(openfire)正在运行,请跳过第1步,并使用您的域帐户从您的花式Gae应用程序接收消息。
了解XMPP 消息传递,以了解其工作原理。
App Engine支持非常有限的XMPP子集。基本上,您可以通过API发送消息,并且可以接收消息(它们作为HTTP请求传入)。
您可以在现有的XMPP服务器上设置外部组件,以便使用您的应用程序引擎代码发送和接收消息。该组件必须跟踪您想要从应用程序发送和接收的任何内容。