私は何か間違っていると思います。 GTalk IDにXMPPメッセージを送信したいが、受信者JIDのリソースを変更しているので、GTalkアプリケーションがメッセージを受信しないようにしたい。Googleトークで異なるjidリソースのメッセージを受信しています
私の問題は、thayは別のリソースを持っていますが、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);
}
出力:
ラファEspillaque、18:33 - あなたは応じるべきではありません!
[email protected]、18:33 - [email protected]/myownresource453242352あなたは応答しないでください!
何が問題なのですか。
UPDATE:
は、今私はaSmackクライアントから[email protected]/botにメッセージを送ることだし、それは私のクライアントで私にメッセージを再送信されます。
問題はGTalk for Gmailで、GTalk for Androidは送信されたすべてのメッセージを登録していますが、アプリの応答を受信しません。他のクライアントは私がそれらと共に送られなかったメッセージを表示しません。
私のメッセージを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);
}
CLIENT:
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("[email protected]",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();
}
最後の事:私はスタンザaSmack ISNから受信AppEngineのログで見てきましたノーマルタイプですがチャットタイプです。
助けてくれてありがとう!
最後のもの:クライアントとGmailから同時に接続し、クライアントと通信することで、Gmailの動作をテストできます。 Gmailがあなたのメッセージを受信しています。
もう一度おねがいします。
別のもの: 私のゴールキーパーは、XMPPを使用して2人のゲームクライアントを自分のGmailアカウントと通信します。あなたは別のことを知っていますか?
どのGoogleトーククライアントをお使いですか? Gmail、ダウンロードクライアント(googletalk.exe)、Google+、Pidgin、その他何か? –
私は共感、GTalk for WindowsとGmail – Rafaesp