2009-10-29 60 views
3

我可以知道你們用什麼集成技術來實現外部組件到現有的XMPP服務器(例如ejabberd或OpenFire)。是通過直接發送xmpp消息給其他用戶@ externaldomain還是使用像urlfetch這樣的機制?將GAE XMPP服務作爲外部組件實現到現有的XMPP服務器(例如ejabberd或OpenFire)

+0

'執行外部組件'?你想達到什麼目的? – 2009-10-29 09:49:06

+0

gae無法使用xmpp,所以我想安裝外部openfire並使用pubsub。我的smack pubsub客戶端也將安裝在外部服務器上 – cometta 2009-10-29 10:48:24

回答

6

谷歌應用程序引擎(GAE)不支持XMPP就像CLIENT

隨着XMPP Gae JAVA client功能,您可以:

發送信息

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可以只是[email protected] OR [email protected] 因爲谷歌域尚不支持。

例如,你可以製作一個玩具GAE應用程序與一個簡單的頁面:

  1. 一個HTML格式發送文本
  2. 消息顯示列表的HTML表格接收並存儲到大表。

要測試你的應用程序:

  1. 上jabber.org創建一個帳戶
  2. 下載啪
  3. 嘗試從拍擊將消息發送到[email protected]
  4. 嘗試發送消息從Gae App到[email protected]

如果你有你的個人XMPP服務器(openfire)啓動並運行,只需跳過第1步並使用您的域帳戶接收來自您喜歡的Gae App的消息。

看看XMPP message delivery瞭解它是如何工作的。

+0

@systempuntoout,你可以評論這個帖子http://stackoverflow.com/questions/2570800/appspot-xmpp-talk-with-jabber-org – cometta 2010-04-04 03:37:16

1

App Engine支持XMPP非常有限的子集。基本上,您可以發送消息(通過API),並且您可以接收消息(它們以HTTP請求的形式出現)。

Java API
Python API

你可以拼湊現有的XMPP服務器上的外部組件,發送和接收與您的應用程序引擎代碼的消息。該組件必須跟蹤您想要從您的應用發送和接收的任何內容。

+0

關於如何使用外部xmpp與gae的任何文章/參考? – cometta 2010-03-28 08:11:03

+0

您不需要做任何特殊的事情就可以與XMPP中的組件進行對話。您只需像以前一樣使用jid發送/接收消息。請注意,這是關於GAE XMPP可以做的所有事情。您喜歡的組件必須位於您運行的另一臺服務器上。 – 2010-03-28 13:43:28

相關問題