-1
我正在使用Smack XMPP創建一個聊天應用程序。除閱讀/遞送報告外,一切都運行良好。在smack XMPP中發送Message.Type.normal android
這是怎麼了發送送達報告:
{
Message message = new Message();
message.setTo(chatMessage.getReceiver());
message.setType(Message.Type.normal);
message.setFrom(chatMessage.getSender());
message.setStanzaId(chatMessage.getReceiver() + "_" + CommonMethods.getCurrentGMTTime(0));
ChatMarker_File_XMPP_SERVER chatMarker_file_xmpp_server=new ChatMarker_File_XMPP_SERVER("received","urn:xmpp:chat-markers:0" , true);
chatMarker_file_xmpp_server.setIdValue(chatMessage.getMsgid());
message.addExtension(chatMarker_file_xmpp_server);
Mychat = ChatManager.getInstanceFor(connection).createChat(
message.getTo() + "@"
+ context.getString(R.string.server),
mMessageListener);
try {
if (connection.isAuthenticated()) {
/********************************************************
* ******** MESSAGE SEND **********************
***/
Mychat.sendMessage(message);
} else {
login();
}
} catch (SmackException.NotConnectedException e) {
Log.e("xmpp.SendMessage()", "msg Not sent!-Not Connected!");
} catch (Exception e) {
Log.e("SendMessage()-Exception",
"msg Not sent!" + e.getMessage());
}
}
但問題是Mychat.sendMessage(message);
的SendMessage
方法就是做這個
/**
* Sends a message to the other chat participant. The thread ID, recipient,
* and message type of the message will automatically set to those of this chat.
*
* @param message the message to send.
* @throws NotConnectedException
*/
public void sendMessage(Message message) throws NotConnectedException {
// Force the recipient, message type, and thread ID since the user elected
// to send the message through this chat object.
message.setTo(participant);
message.setType(Message.Type.chat);
message.setThread(threadID);
chatManager.sendMessage(this, message);
}
現在雖然我明確設置「爲messageType」到「正常'但'sendMessage()'將它再次轉換爲Type.Chat
。
我已經檢查了其他可能的方法和文檔,以便能以某種方式發送消息類型正常但找不到任何東西。
謝謝