當前位置: 首頁>>代碼示例>>Java>>正文


Java Message.setType方法代碼示例

本文整理匯總了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;
}
 
開發者ID:Blazemeter,項目名稱:jmeter-bzm-plugins,代碼行數:23,代碼來源:SendMessage.java

示例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);
}
 
開發者ID:ukevgen,項目名稱:BizareChat,代碼行數:18,代碼來源:QuickbloxGroupXmppConnection.java

示例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);
    }
}
 
開發者ID:ukevgen,項目名稱:BizareChat,代碼行數:25,代碼來源:QuickbloxPrivateXmppConnection.java

示例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);
    }
}
 
開發者ID:ukevgen,項目名稱:BizareChat,代碼行數:24,代碼來源:QuickbloxPrivateXmppConnection.java

示例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);
    }
}
 
開發者ID:ukevgen,項目名稱:BizareChat,代碼行數:27,代碼來源:QuickbloxPrivateXmppConnection.java

示例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);
    }
}
 
開發者ID:ukevgen,項目名稱:BizareChat,代碼行數:24,代碼來源:QuickbloxPrivateXmppConnection.java

示例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);
    }
}
 
開發者ID:Blazemeter,項目名稱:jmeter-bzm-plugins,代碼行數:12,代碼來源:SendMessage.java

示例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);
}
 
開發者ID:TTalkIM,項目名稱:Smack,代碼行數:16,代碼來源:Chat.java

示例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());
}
 
開發者ID:TTalkIM,項目名稱:Smack,代碼行數:8,代碼來源:ChatConnectionTest.java

示例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());
}
 
開發者ID:TTalkIM,項目名稱:Smack,代碼行數:8,代碼來源:ChatConnectionTest.java

示例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());
}
 
開發者ID:TTalkIM,項目名稱:Smack,代碼行數:8,代碼來源:ChatConnectionTest.java

示例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());
}
 
開發者ID:TTalkIM,項目名稱:Smack,代碼行數:9,代碼來源:ChatConnectionTest.java

示例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());
}
 
開發者ID:TTalkIM,項目名稱:Smack,代碼行數:9,代碼來源:ChatConnectionTest.java

示例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());
}
 
開發者ID:TTalkIM,項目名稱:Smack,代碼行數:11,代碼來源:ChatConnectionTest.java

示例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());
}
 
開發者ID:TTalkIM,項目名稱:Smack,代碼行數:7,代碼來源:ChatConnectionTest.java


注:本文中的org.jivesoftware.smack.packet.Message.setType方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。