繁体   English   中英

将GAE XMPP服务实现为现有XMPP服务器(例如ejabberd或OpenFire)的外部组件

[英]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.comfoo@yourappid.appspotchat.com,因为尚不支持Google域。

例如,您可以制作一个带有以下简单页面的Toy Gae应用程序:

  1. 发送文本的HTML表单
  2. 一个html表,显示已接收并存储到大表的消息列表。

要测试您的应用程序:

  1. 在jabber.org上创建一个帐户
  2. 下载Smack
  3. 尝试将邮件从Smack发送到yourappid@appspot.com
  4. 尝试将消息从Gae App发送到youraccount@jabber.org

如果您的个人XMPP服务器(openfire)已启动并正在运行,只需跳过第1步,并使用您的域帐户从您喜欢的Gae App接收消息。

查看XMPP 消息传递以了解其工作原理。

App Engine支持XMPP的非常有限的子集。 基本上,您可以发送消息(通过API),也可以接收消息(它们作为HTTP请求进入)。

Java API
Python API

您可以在现有XMPP服务器上安装外部组件,以使用您的应用引擎代码发送和接收消息。 该组件将必须跟踪您想要从应用程序发送和接收的任何内容。

暂无
暂无

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

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