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

发布于 2024-08-09 02:22:41 字数 119 浏览 3 评论 0原文

我可以知道你们使用什么集成技术来实现现有 XMPP 服务器的外部组件(例如 ejabberd 或 OpenFire)。是直接发送xmpp消息到另一个user@externaldomain还是使用像urlfetch这样的机制?

may i know what integration technique that you folks use to implement external component to an existing XMPP server (e.g. ejabberd or OpenFire) . Is it through sending xmpp message to another user@externaldomain directly or using mechanism like urlfetch?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

赤濁 2024-08-16 02:22:41

Google 应用引擎 (Gae) 确实支持 XMPP,就像 CLIENT 一样。

借助 XMPP Gae JAVA 客户端功能,您可以:

发送消息

JID jid = new JID("[email protected]");
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 可以只是[电子邮件受保护][电子邮件受保护]
因为尚不支持 Google 域名。

例如,您可以使用一个简单的页面制作一个玩具 Gae 应用程序,其中包含:

  1. 一个用于发送文本的
  2. html 表单 一个显示接收到的消息列表并存储到大表中的 html 表格。

要测试您的应用程序:

  1. 在 jabber.org 上创建帐户
  2. 下载 Smack
  3. 尝试从 Smack 发送消息到 [电子邮件受保护]
  4. 尝试从 Gae 应用程序发送消息至 [ 电子邮件;protected]

如果您已启动并运行个人 XMPP 服务器 (openfire),只需跳过步骤 1 并使用您的域帐户即可从您精美的 Gae 应用程序接收消息。

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

Google app engine (Gae) does support XMPP just as CLIENT.

With XMPP Gae JAVA client feature you can:

SEND MESSAGE

JID jid = new JID("[email protected]");
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);               
}

RECEIVE MESSAGE

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
  }
}

Remember that JIDs can just be [email protected] OR [email protected]
because Google domains are not supported yet.

For example, you could craft a toy Gae application with a simple page with:

  1. An html form to send text
  2. An html table that display the list of messages received and stored to big table.

To test your application:

  1. Create an account on jabber.org
  2. Download Smack
  3. Try to send a message from Smack to [email protected]
  4. Try to send a message from Gae App to [email protected]

In case you have your personal XMPP server (openfire) up and running, simply skip step 1 and use your domain account to receive message from your fancy Gae App.

Have a look to XMPP message delivery to understand how this works.

つ可否回来 2024-08-16 02:22:41

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

Java API
Python API

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

App Engine supports a very limited subset of XMPP. Basically, you can send messages (through the API), and you can receive messages (they come in as HTTP requests).

Java API
Python API

You could rig up an external component on your existing XMPP server, to send and receive messages with your app engine code. That component would have to keep track of whatever it is you want to send and receive from your app.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文