本文整理匯總了Java中org.jivesoftware.smack.packet.Message.setType方法的典型用法代碼示例。如果您正苦於以下問題:Java Message.setType方法的具體用法?Java Message.setType怎麽用?Java Message.setType使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類org.jivesoftware.smack.packet.Message
的用法示例。
在下文中一共展示了Message.setType方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: perform
import org.jivesoftware.smack.packet.Message; //導入方法依賴的package包/類
@Override
public SampleResult perform(JMeterXMPPSampler sampler, SampleResult res) throws Exception {
// sending message
String recipient = sampler.getPropertyAsString(RECIPIENT);
String body = sampler.getPropertyAsString(BODY);
boolean wait_response = sampler.getPropertyAsBoolean(WAIT_RESPONSE);
if (wait_response) {
body += "\r\n" + System.currentTimeMillis() + "@" + NEED_RESPONSE_MARKER;
}
Message msg = new Message(recipient);
msg.setType(Message.Type.fromString(sampler.getPropertyAsString(TYPE, Message.Type.normal.toString())));
msg.addBody("", body);
res.setSamplerData(msg.toXML().toString());
sampler.getXMPPConnection().sendPacket(msg);
res.setSamplerData(msg.toXML().toString()); // second time to reflect the changes made to packet by conn
if (wait_response) {
return waitResponse(res, recipient);
}
return res;
}
示例2: sendMessage
import org.jivesoftware.smack.packet.Message; //導入方法依賴的package包/類
public void sendMessage(String body, String chatJid, long timestamp) throws SmackException {
Random random = new Random(timestamp + body.length() + chatJid.length());
Log.d(TAG, "Sending message to : " + chatJid);
MultiUserChat chat = MultiUserChatManager.getInstanceFor(groupChatConnection)
.getMultiUserChat(chatJid);
chat.addMessageListener(this);
Message message = new Message();
QuickbloxChatExtension extension = new QuickbloxChatExtension();
extension.setProperty("date_sent", timestamp + "");
message.setStanzaId(StanzaIdUtil.newStanzaId());
message.setBody(body);
message.addExtension(extension);
message.setType(Message.Type.chat);
chat.sendMessage(message);
}
示例3: sendDisplayedReceipt
import org.jivesoftware.smack.packet.Message; //導入方法依賴的package包/類
public void sendDisplayedReceipt(String receiverJid, String stanzaId, String dialog_id) {
Chat chat;
if ((chat = privateChats.get(receiverJid)) == null) {
chat = ChatManager.getInstanceFor(privateChatConnection).createChat(receiverJid, this);
privateChats.put(receiverJid, chat);
}
Message message = new Message(receiverJid);
Displayed read = new Displayed(stanzaId);
QuickbloxChatExtension extension = new QuickbloxChatExtension();
extension.setProperty("dialog_id", dialog_id);
message.setStanzaId(StanzaIdUtil.newStanzaId());
message.setType(Message.Type.chat);
message.addExtension(read);
message.addExtension(extension);
try {
chat.sendMessage(message);
} catch (SmackException.NotConnectedException ex) {
Logger.logExceptionToFabric(ex);
offlineMessages.add(message);
}
}
示例4: sendReceivedReceipt
import org.jivesoftware.smack.packet.Message; //導入方法依賴的package包/類
public void sendReceivedReceipt(String receiverJid, String stanzaId, String dialog_id) {
Chat chat;
if ((chat = privateChats.get(receiverJid)) == null) {
chat = ChatManager.getInstanceFor(privateChatConnection).createChat(receiverJid, this);
privateChats.put(receiverJid, chat);
}
Message message = new Message(receiverJid);
Received delivered = new Received(stanzaId);
QuickbloxChatExtension extension = new QuickbloxChatExtension();
extension.setProperty("dialog_id", dialog_id);
message.setStanzaId(StanzaIdUtil.newStanzaId());
message.setType(Message.Type.chat);
message.addExtension(delivered);
message.addExtension(extension);
try {
chat.sendMessage(message);
} catch (SmackException.NotConnectedException ex) {
offlineMessages.add(message);
}
}
示例5: sendPrivateMessage
import org.jivesoftware.smack.packet.Message; //導入方法依賴的package包/類
public void sendPrivateMessage(String body, String receiverJid, long timestamp, String stanzaId) {
Log.d(TAG, "Sending message to : " + receiverJid);
Chat chat;
if ((chat = privateChats.get(receiverJid)) == null) {
chat = ChatManager.getInstanceFor(privateChatConnection).createChat(receiverJid, this);
privateChats.put(receiverJid, chat);
}
QuickbloxChatExtension extension = new QuickbloxChatExtension();
extension.setProperty("date_sent", timestamp + "");
extension.setProperty("save_to_history", "1");
Message message = new Message(receiverJid);
message.setStanzaId(stanzaId);
message.setBody(body);
message.setType(Message.Type.chat);
message.addExtension(new Markable());
message.addExtension(extension);
try {
chat.sendMessage(message);
} catch (SmackException.NotConnectedException ex) {
offlineMessages.add(message);
}
}
示例6: sendPublicMessage
import org.jivesoftware.smack.packet.Message; //導入方法依賴的package包/類
public void sendPublicMessage(String body, String chatJid, long timestamp, String stanzaId) {
Log.d(TAG, "Sending message to : " + chatJid);
MultiUserChat mucChat = publicChats.get(chatJid);
QuickbloxChatExtension extension = new QuickbloxChatExtension();
extension.setProperty("date_sent", timestamp + "");
extension.setProperty("save_to_history", "1");
Message message = new Message(chatJid);
message.setStanzaId(stanzaId);
message.setBody(body);
message.setType(Message.Type.groupchat);
message.addExtension(extension);
try {
if (mucChat != null) {
mucChat.sendMessage(message);
}
} catch (SmackException.NotConnectedException ex) {
offlineMessages.add(message);
}
}
示例7: sendResponseMessage
import org.jivesoftware.smack.packet.Message; //導入方法依賴的package包/類
private void sendResponseMessage(Message inMsg) {
Message outMsg = new Message(inMsg.getFrom());
outMsg.setType(inMsg.getType());
outMsg.addBody("", inMsg.getBody() + "\r\n" + System.currentTimeMillis() + "@" + RESPONSE_MARKER);
log.debug("Responding to message: " + outMsg.toXML());
try {
conn.sendPacket(outMsg);
} catch (SmackException e) {
log.error("Failed to send response", e);
}
}
示例8: sendMessage
import org.jivesoftware.smack.packet.Message; //導入方法依賴的package包/類
/**
* 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);
}
示例9: validateMessageTypeWithDefaults1
import org.jivesoftware.smack.packet.Message; //導入方法依賴的package包/類
@Test
public void validateMessageTypeWithDefaults1() {
Message incomingChat = createChatPacket("134", true);
incomingChat.setType(Type.chat);
processServerMessage(incomingChat);
assertNotNull(listener.getNewChat());
}
示例10: validateMessageTypeWithDefaults2
import org.jivesoftware.smack.packet.Message; //導入方法依賴的package包/類
@Test
public void validateMessageTypeWithDefaults2() {
Message incomingChat = createChatPacket("134", true);
incomingChat.setType(Type.normal);
processServerMessage(incomingChat);
assertNotNull(listener.getNewChat());
}
示例11: validateMessageTypeWithDefaults3
import org.jivesoftware.smack.packet.Message; //導入方法依賴的package包/類
@Test
public void validateMessageTypeWithDefaults3() {
Message incomingChat = createChatPacket("134", true);
incomingChat.setType(Type.groupchat);
processServerMessage(incomingChat);
assertNull(listener.getNewChat());
}
示例12: validateMessageTypeWithNoNormal1
import org.jivesoftware.smack.packet.Message; //導入方法依賴的package包/類
@Test
public void validateMessageTypeWithNoNormal1() {
cm.setNormalIncluded(false);
Message incomingChat = createChatPacket("134", true);
incomingChat.setType(Type.chat);
processServerMessage(incomingChat);
assertNotNull(listener.getNewChat());
}
示例13: validateMessageTypeWithNoNormal2
import org.jivesoftware.smack.packet.Message; //導入方法依賴的package包/類
@Test
public void validateMessageTypeWithNoNormal2() {
cm.setNormalIncluded(false);
Message incomingChat = createChatPacket("134", true);
incomingChat.setType(Type.normal);
processServerMessage(incomingChat);
assertNull(listener.getNewChat());
}
示例14: chatNotMatchedWithTypeNormal
import org.jivesoftware.smack.packet.Message; //導入方法依賴的package包/類
@Test
public void chatNotMatchedWithTypeNormal() {
cm.setNormalIncluded(false);
Message incomingChat = createChatPacket(null, false);
incomingChat.setType(Type.normal);
processServerMessage(incomingChat);
assertNull(listener.getNewChat());
}
示例15: validateMessageTypeWithDefaults4
import org.jivesoftware.smack.packet.Message; //導入方法依賴的package包/類
@Test
public void validateMessageTypeWithDefaults4() {
Message incomingChat = createChatPacket("134", true);
incomingChat.setType(Type.headline);
assertNull(listener.getNewChat());
}