google-app-engine - Google Talk接收具有不同jid资源的消息

标签 google-app-engine xmpp

我想我做错了。
我想将XMPP消息发送到我的GTalk ID,但是我不希望GTalk应用程序接收到该消息,因此我正在更改收件人JID的资源。

我的问题是,尽管GTalk具有不同的资源,但它们仍在接收所有消息。

我的代码:

public void doPost(HttpServletRequest req,
        HttpServletResponse resp) throws IOException {

    // Parse incoming message
    XMPPService xmpp = XMPPServiceFactory.getXMPPService();
    Message msg = xmpp.parseMessage(req);
    JID jid = msg.getFromJid();
    String body = msg.getBody();

    String jidID = jid.getId().split("/")[0];
    JID jid2 = new JID(jidID+"/myownresource453242352");

    String response =  jid2.getId() + " " + body;

    // Send out response
    msg = new MessageBuilder().withRecipientJids(jid2).withBody(response).build();
    xmpp.sendMessage(msg);

}

输出:
  • Rafa Espillaque,18:33-
    你不应该回应!
  • prueba-gae-gdx @ appspot.com,18:33-
    rafaespillaque@gmail.com/myownresource453242352您不应该回应!

  • 怎么了?

    更新:

    现在,我正在从aSmack客户端向myapp@appspot.com/bot发送消息,它正在将消息重新发送给我的客户端。

    问题是Gmail的GTalk和Android的GTalk正在注册所有已发送的邮件,但它们未收到应用程序的响应。其他客户不显示我未与他们一起发送的消息。

    我可以将邮件隐藏到Gmail和Android吗?

    我的代码:

    服务器
      public void doPost(HttpServletRequest req,
      HttpServletResponse resp) throws IOException {
      LOG.setLevel(Level.INFO);
    // Parse incoming message
    XMPPService xmpp = XMPPServiceFactory.getXMPPService();
    Message msg = xmpp.parseMessage(req);
    
    LOG.info(msg.getStanza());
    
    JID jid = msg.getFromJid();
    String body = msg.getBody();
    
    String response =  "FullID: "+jid.getId()+" El mensaje recibido es: "+body;
    
    // Send out response
    msg = new MessageBuilder().
        withRecipientJids(jid)
        .withMessageType(MessageType.NORMAL)
        .withBody(response)
        .build();
    xmpp.sendMessage(msg);
    

    }

    客户:
    ConnectionConfiguration connectionConfiguration = new ConnectionConfiguration("talk.google.com", 5222, "gmail.com");
                        XMPPConnection connection = new XMPPConnection(connectionConfiguration);
                        try {
                            Log.i("TAG","Trying to connect");
                            connection.connect();
                            Log.i("TAG","Connected");
                            SASLAuthentication.supportSASLMechanism("PLAIN", 0);
                            Log.i("TAG","Trying to Log In");
                            connection.login("rafaespillaque@gmail.com",mypass, mires");
                            Log.i("TAG","Logged In");
                        } catch (XMPPException e) {
                            e.printStackTrace();
                            Log.i("TAG","Problem connecting or logging in");
                        }
                        //Creating chat object for processing friend chat
                        Chat chat = connection.getChatManager().createChat(Server, new MessageListener() {
                            //Overriding process message function of MessageListener Interface which will be 
                                        //called whenever a message is received
                            @Override
                            public void processMessage(Chat c, Message m) {
                                //Displaying message sent by friend
                                //System.out.println(friendId+ " : " + m.getBody());
                                Log.i("TAG", m.getBody());
                                message = m.getBody();
                            }   
                        });
                        try {
                            Message out = new Message();
                            out.setBody("Definitivo22222222");
                            out.setType(Type.normal);
                            chat.sendMessage(out);
                            Log.i("TAG", "Mensaje enviado");
                        } catch (XMPPException e) {
                            Log.i("TAG", "No se envió el mensaje");
                            e.printStackTrace();
                        }
    

    最后一件事:我在AppEngine日志中看到,从aSmack接收到的Stanza不是普通类型,而是聊天类型。

    感谢您的帮助!

    倒数第二件事:您可以通过同时连接任何客户端和Gmail并与客户端交谈来测试Gmail的功能。 Gmail正在接收您的邮件。

    再次感谢。

    另一件事:
    我的目标是使用XMPP通过其gmail帐户与2个游戏客户端进行通信。你知道替代品吗?

    最佳答案

    参见RFC 6120, section 10.5.4:

    If the JID contained in the 'to' attribute is of the form localpart@domainpart/resourcepart and the user exists but there is no connected resource that exactly matches the full JID, the stanza SHOULD be processed as if the JID were of the form localpart@domainpart as described under Section 10.5.3.2.



    如果您发送到无效资源,则服务器会将其视为已将其发送到裸机JID。在GoogleTalk上,这涉及所有非负优先级资源。

    关于google-app-engine - Google Talk接收具有不同jid资源的消息,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8524263/

    相关文章:

    google-app-engine - Django/GAE 中基于浏览器的策略游戏。型号建议?

    xmpp - "Voting"XMPP协议(protocol)机制

    java - 如何在 App Engine 上实现 GCM CCS(XMPP) 服务器?

    c - 无法将我的应用程序服务器连接到 FCM XMPP 服务器

    google-app-engine - 将 App Engine 模块(以前的后端)映射到单独的 Go 程序

    google-app-engine - 拥有一对多关系和拥有一对多双向关系之间的区别(Google App Engine Java Api)

    java - 在 OpenFire 中刷新 VCard

    android - 在 Android 中将 Facebook 聊天与 Asmack API 集成

    google-app-engine - 保存和加载自定义类型

    python - 弹出警报的 GAE/Python 最佳实践?