[英]Super simple XMPP server or advice for a simple custom Openfire component
[英]implementing GAE XMPP service as an external component to an existing XMPP server (e.g. ejabberd or OpenFire)
我是否可以知道您所使用的集成技术来将外部组件实现到现有XMPP服务器(例如ejabberd或OpenFire)。 是通过直接将xmpp消息发送到另一个user @ externaldomain还是使用urlfetch之类的机制?
Google应用程序引擎(Gae)与CLIENT一样支持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
}
}
请记住,JID可以只是yourappid@appspot.com或foo@yourappid.appspotchat.com,因为尚不支持Google域。
例如,您可以制作一个带有以下简单页面的Toy Gae应用程序:
要测试您的应用程序:
如果您的个人XMPP服务器(openfire)已启动并正在运行,只需跳过第1步,并使用您的域帐户从您喜欢的Gae App接收消息。
查看XMPP 消息传递以了解其工作原理。
App Engine支持XMPP的非常有限的子集。 基本上,您可以发送消息(通过API),也可以接收消息(它们作为HTTP请求进入)。
您可以在现有XMPP服务器上安装外部组件,以使用您的应用引擎代码发送和接收消息。 该组件将必须跟踪您想要从应用程序发送和接收的任何内容。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.