[英]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.