本文整理匯總了Java中org.jivesoftware.smack.packet.Message.setProperty方法的典型用法代碼示例。如果您正苦於以下問題:Java Message.setProperty方法的具體用法?Java Message.setProperty怎麽用?Java Message.setProperty使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類org.jivesoftware.smack.packet.Message
的用法示例。
在下文中一共展示了Message.setProperty方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: sendProjChromMsg
import org.jivesoftware.smack.packet.Message; //導入方法依賴的package包/類
/**
* 發送信息到雲同步室
*
* @param room 雲同步室
* @param msg 將要發送的信息
*/
public void sendProjChromMsg(MultiUserChat room, Object msg) {
if (!room.isJoined())
return;
try {
Message message = new Message(room.getRoom(), Message.Type.groupchat);
message.setBody(SysUtil.getInstance().getDateAndTimeFormated());
message.setProperty(MSGCLOUD, msg);
room.sendMessage(message);
} catch (XMPPException e) {
e.printStackTrace();
}
}
示例2: testProperties
import org.jivesoftware.smack.packet.Message; //導入方法依賴的package包/類
public void testProperties() {
try {
Chat newChat = getConnection(0).getChatManager().createChat(getFullJID(1), null);
PacketCollector collector = getConnection(1)
.createPacketCollector(new ThreadFilter(newChat.getThreadID()));
Message msg = new Message();
msg.setSubject("Subject of the chat");
msg.setBody("Body of the chat");
msg.setProperty("favoriteColor", "red");
msg.setProperty("age", 30);
msg.setProperty("distance", 30f);
msg.setProperty("weight", 30d);
msg.setProperty("male", true);
msg.setProperty("birthdate", new Date());
newChat.sendMessage(msg);
Message msg2 = (Message) collector.nextResult(2000);
assertNotNull("No message was received", msg2);
assertEquals("Subjects are different", msg.getSubject(), msg2.getSubject());
assertEquals("Bodies are different", msg.getBody(), msg2.getBody());
assertEquals(
"favoriteColors are different",
msg.getProperty("favoriteColor"),
msg2.getProperty("favoriteColor"));
assertEquals(
"ages are different",
msg.getProperty("age"),
msg2.getProperty("age"));
assertEquals(
"distances are different",
msg.getProperty("distance"),
msg2.getProperty("distance"));
assertEquals(
"weights are different",
msg.getProperty("weight"),
msg2.getProperty("weight"));
assertEquals(
"males are different",
msg.getProperty("male"),
msg2.getProperty("male"));
assertEquals(
"birthdates are different",
msg.getProperty("birthdate"),
msg2.getProperty("birthdate"));
}
catch (XMPPException e) {
e.printStackTrace();
fail(e.getMessage());
}
}