Java 类org.jivesoftware.smack.packet.Message 实例源码

项目:jmeter-bzm-plugins    文件:SendMessage.java   
@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;
}
项目:jmeter-bzm-plugins    文件:SendMessage.java   
private SampleResult waitResponse(SampleResult res, String recipient) throws InterruptedException, SmackException {
    long time = 0;
    do {
        Iterator<Message> packets = responseMessages.iterator();
        Thread.sleep(conn.getPacketReplyTimeout() / 100); // optimistic
        while (packets.hasNext()) {
            Packet packet = packets.next();
            Message response = (Message) packet;
            if (XmppStringUtils.parseBareAddress(response.getFrom()).equals(recipient)) {
                packets.remove();
                res.setResponseData(response.toXML().toString().getBytes());
                if (response.getError() != null) {
                    res.setSuccessful(false);
                    res.setResponseCode("500");
                    res.setResponseMessage(response.getError().toString());
                }
                return res;
            }
        }
        time += conn.getPacketReplyTimeout() / 10;
        Thread.sleep(conn.getPacketReplyTimeout() / 10);
    } while (time < conn.getPacketReplyTimeout());
    throw new SmackException.NoResponseException();
}
项目:jmeter-bzm-plugins    文件:SendMessage.java   
@Override
public void addUI(JComponent mainPanel, GridBagConstraints labelConstraints, GridBagConstraints editConstraints) {
    addToPanel(mainPanel, labelConstraints, 0, 0, new JLabel("Type: ", JLabel.RIGHT));
    addToPanel(mainPanel, editConstraints, 1, 0, msgType = new JComboBox<>());
    msgType.addItem(Message.Type.normal);
    msgType.addItem(Message.Type.chat);
    msgType.addItem(Message.Type.groupchat);
    msgType.addItem(Message.Type.headline);
    msgType.addItem(Message.Type.error);

    addToPanel(mainPanel, labelConstraints, 0, 1, new JLabel("Recipient: ", JLabel.RIGHT));
    addToPanel(mainPanel, editConstraints, 1, 1, msgRecipient = new JTextField(20));

    addToPanel(mainPanel, labelConstraints, 0, 2, new JLabel("Message Text: ", JLabel.RIGHT));
    addToPanel(mainPanel, editConstraints, 1, 2, msgBody = new JTextArea(5, 20));

    addToPanel(mainPanel, labelConstraints, 0, 3, new JLabel("Wait for Response: ", JLabel.RIGHT));
    addToPanel(mainPanel, editConstraints, 1, 3, waitResponse = new JCheckBox("(message that expects response should be auto-responded by another JMeter thread)"));
}
项目:jmeter-bzm-plugins    文件:SendMessage.java   
@Override
public void processPacket(Packet packet) throws SmackException.NotConnectedException {
    if (packet instanceof Message) {
        Message inMsg = (Message) packet;
        if (inMsg.getBody() != null) {
            if (inMsg.getBody().endsWith(NEED_RESPONSE_MARKER)) {
                if (inMsg.getExtension(NS_DELAYED) == null) {
                    log.debug("Will respond to message: " + inMsg.toXML());
                    sendResponseMessage(inMsg);
                } else {
                    log.debug("Will not consider history message: " + inMsg.toXML());
                }
            } else if (inMsg.getBody().endsWith(RESPONSE_MARKER)) {
                responseMessages.add(inMsg);
            }
        }
    }
}
项目:BizareChat    文件:QuickbloxGroupXmppConnection.java   
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);
}
项目:BizareChat    文件:QuickbloxPrivateXmppConnection.java   
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);
    }
}
项目:BizareChat    文件:QuickbloxPrivateXmppConnection.java   
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);
    }
}
项目:BizareChat    文件:QuickbloxPrivateXmppConnection.java   
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);
    }
}
项目:BizareChat    文件:QuickbloxPrivateXmppConnection.java   
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);
    }
}
项目:BizareChat    文件:QuickbloxPrivateXmppConnection.java   
@Override
public void reconnectionSuccessful() {
    connected = true;
    if (!offlineMessages.isEmpty()) {
        JobExecutor.getInstance().execute(() -> {
            while (!offlineMessages.isEmpty()) {
                try {
                    if (!publicChatToLeave.isEmpty()) {
                        publicChats.get(publicChatToLeave).leave();
                        publicChatToLeave = "";
                    }
                    Message message = offlineMessages.peek();
                    privateChatConnection.sendStanza(message);
                } catch (SmackException ex) {
                    Logger.logExceptionToFabric(ex);
                    break;
                }
                offlineMessages.poll();
            }
        });
    }
    Log.d(TAG, "Reconnection successful");
}
项目:BizareChat    文件:BizareChatMessageService.java   
void processPublicMessage(Message message) {
    JobExecutor.getInstance().execute(() -> {
        MessageModel messageModel = getMessageModel(message);
        MessageModel messageModelFromDb = daoSession.getMessageModelDao()
                .queryBuilder()
                .where(MessageModelDao.Properties.MessageId.eq(message.getStanzaId()))
                .unique();
        if (messageModelFromDb != null) {
            messageModelFromDb.setMessageId(messageModel.getMessageId());
            messageModelFromDb.setRead(MessageState.DELIVERED);
            daoSession.getMessageModelDao().deleteByKeyInTx(message.getStanzaId());
        } else {
            messageModelFromDb = messageModel;
        }

        savePublicMessageToDb(messageModelFromDb);

        if (messageModelFromDb.getSenderId().longValue() != CurrentUser.getInstance().getCurrentUserId()) {
            EventBus.getDefault().post(new PublicMessageEvent(messageModel));
        }
    });
}
项目:mangosta-android    文件:RoomManager.java   
public void updateTypingStatus(final ChatState chatState, final String jid, final int chatType) {
    if (!Preferences.isTesting()) {
        new Thread(new Runnable() {
            @Override
            public void run() {
                try {
                    Message message = new Message(JidCreate.from(jid));
                    message.addExtension(new ChatStateExtension(chatState));

                    if (chatType == Chat.TYPE_1_T0_1) {
                        message.setType(Message.Type.chat);
                    } else {
                        message.setType(Message.Type.groupchat);
                    }

                    sendMessageDependingOnType(message, jid, chatType);
                } catch (Exception e) {
                    e.printStackTrace();
                }
            }
        }).start();
    }
}
项目:mangosta-android    文件:XMPPSession.java   
private void saveMessage(Message message) {
    String messageId = assignMessageId(message);

    if (RealmManager.getInstance().chatMessageExists(messageId)) { // message sent confirmation
        manageMessageAlreadyExists(message, null, messageId);

    } else if (isMessageCorrection(message)) { // message correction
        manageMessageCorrection(message, null);

    } else { // normal message received
        manageMessageReceived(message, null, messageId, false);

        if (canBeTextMessageOrSticker(message)) {
            MessageNotifications.chatMessageNotification(messageId);
        }
    }
}
项目:mangosta-android    文件:XMPPSession.java   
private void manageMessageCorrection(Message message, Date delayDate) {
    MessageCorrectExtension messageCorrectExtension = MessageCorrectExtension.from(message);
    String newMessageBody = message.getBody();
    String idInitialMessage = messageCorrectExtension.getIdInitialMessage();

    Realm realm = RealmManager.getInstance().getRealm();
    realm.beginTransaction();

    ChatMessage chatMessage = realm.where(ChatMessage.class)
            .equalTo("messageId", idInitialMessage)
            .findFirst();

    if (chatMessage != null) {
        chatMessage.setContent(newMessageBody);
        manageDelayDate(delayDate, chatMessage);
        realm.copyToRealmOrUpdate(chatMessage);
    }

    realm.commitTransaction();
    realm.close();
}
项目:Camel    文件:XmppBinding.java   
public Map<String, Object> extractHeadersFromXmpp(Packet xmppPacket, Exchange exchange) {
    Map<String, Object> answer = new HashMap<String, Object>();

    PacketExtension jpe = xmppPacket.getExtension(JivePropertiesExtension.NAMESPACE);
    if (jpe != null && jpe instanceof JivePropertiesExtension) {
        extractHeadersFrom((JivePropertiesExtension)jpe, exchange, answer);
    }
    if (jpe != null && jpe instanceof DefaultPacketExtension) {
        extractHeadersFrom((DefaultPacketExtension)jpe, exchange, answer);
    }

    if (xmppPacket instanceof Message) {
        Message xmppMessage = (Message) xmppPacket;
        answer.put(XmppConstants.MESSAGE_TYPE, xmppMessage.getType());
        answer.put(XmppConstants.SUBJECT, xmppMessage.getSubject());
        answer.put(XmppConstants.THREAD_ID, xmppMessage.getThread());
    } else if (xmppPacket instanceof PubSub) {
        PubSub pubsubPacket = (PubSub) xmppPacket;
        answer.put(XmppConstants.MESSAGE_TYPE, pubsubPacket.getType());
    }
    answer.put(XmppConstants.FROM, xmppPacket.getFrom());
    answer.put(XmppConstants.PACKET_ID, xmppPacket.getPacketID());
    answer.put(XmppConstants.TO, xmppPacket.getTo());

    return answer;
}
项目:mangosta-android    文件:XMPPSession.java   
private void manageConfigurationsChange(Message message, ChatMessage chatMessage, Chat chatRoom) {
    if (hasConfigurationChangeExtension(message)) {
        MUCLightElements.ConfigurationsChangeExtension configurationsChangeExtension = MUCLightElements.ConfigurationsChangeExtension.from(message);

        String roomName = configurationsChangeExtension.getRoomName();
        String subject = configurationsChangeExtension.getSubject();

        if (roomName != null) {
            chatRoom.setName(roomName);
        }

        if (subject != null) {
            chatRoom.setSubject(subject);
        }

        chatMessage.setType(ChatMessage.TYPE_ROOM_NAME_CHANGED);
    }
}
项目:PracticeCode    文件:XSCHelper.java   
/**
 * 加入信息聊天室
 *
 * @param password 登录密码
 * @param roomName 房间名称
 * @param maxMsg   接收离线消息数
 * @param handler  处理信息的Handler
 */
public void joinChatRoom(final String roomName, final String password, final int maxMsg, final Handler handler) {
    joinRoom(roomName, password, 1, maxMsg, new Handler(){
        @Override
        public void handleMessage(android.os.Message msg) {
            android.os.Message message = new android.os.Message();
            message.what = msg.what;
            message.obj = msg.obj;
            switch (msg.what) {
                case FAILURE:
                    handler.sendEmptyMessage(FAILURE);
                    break;
                case SUCCESS:
                    handler.sendMessage(message);
                    break;
                case MESSAGE:
                    Bundle args = new Bundle();
                    args.putString(MSGFROM, ((Message) msg.obj).getFrom());
                    args.putString(MSGBODY, ((Message) msg.obj).getBody());
                    message.setData(args);
                    handler.sendMessage(message);
                    break;
            }
        }
    });
}
项目:lider    文件:XMPPClientImpl.java   
/**
 * Send provided message to provided JID. Message type is always NORMAL.
 * 
 * @param message
 * @param jid
 * @throws NotConnectedException
 */
public void sendMessage(String message, String jid) throws NotConnectedException {

    try{
    String jidFinal = getFullJid(jid);
    logger.debug("Sending message: {} to user: {}", new Object[] { message, jidFinal });
    Message msg = new Message(jidFinal, Message.Type.normal);
    msg.setBody(message);
    connection.sendStanza(msg);
    logger.debug("Successfully sent message to user: {}", jidFinal);}
    catch(NotConnectedException ex){
        ex.printStackTrace();

        try {
            logger.debug("Tring again to connect..");
            init();
        } catch (Exception e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }
    }
}
项目:Smack    文件:ChatStateManager.java   
public void processMessage(Chat chat, Message message) {
    ExtensionElement extension = message.getExtension(NAMESPACE);
    if (extension == null) {
        return;
    }

    ChatState state;
    try {
        state = ChatState.valueOf(extension.getElementName());
    }
    catch (Exception ex) {
        return;
    }

    fireNewChatState(chat, state);
}
项目:Camel    文件:XmppConsumer.java   
public void processMessage(Chat chat, Message message) {
    if (LOG.isDebugEnabled()) {
        LOG.debug("Received XMPP message for {} from {} : {}", new Object[]{endpoint.getUser(), endpoint.getParticipant(), message.getBody()});
    }

    Exchange exchange = endpoint.createExchange(message);

    if (endpoint.isDoc()) {
        exchange.getIn().setHeader(XmppConstants.DOC_HEADER, message);
    }
    try {
        getProcessor().process(exchange);
    } catch (Exception e) {
        exchange.setException(e);
    } finally {
        // must remove message from muc to avoid messages stacking up and causing OutOfMemoryError
        // pollMessage is a non blocking method
        // (see http://issues.igniterealtime.org/browse/SMACK-129)
        if (muc != null) {
            muc.pollMessage();
        }
    }
}
项目:Camel    文件:XmppRouteTest.java   
protected Object assertReceivedValidExchange() throws Exception {
    // lets wait on the message being received
    assertTrue(latch.await(5, TimeUnit.SECONDS));

    assertNotNull(receivedExchange);
    XmppMessage receivedMessage = (XmppMessage)receivedExchange.getIn();

    assertEquals("cheese header", 123, receivedMessage.getHeader("cheese"));
    Object body = receivedMessage.getBody();
    XmppRouteTest.LOG.debug("Received body: " + body);
    Message xmppMessage = receivedMessage.getXmppMessage();
    assertNotNull(xmppMessage);

    XmppRouteTest.LOG.debug("Received XMPP message: " + xmppMessage.getBody());
    return body;
}
项目:lider    文件:UserSessionListener.java   
@Override
public void processPacket(Stanza packet) throws NotConnectedException {
    try {
        if (packet instanceof Message) {

            Message msg = (Message) packet;
            logger.info("Register message received from => {}, body => {}", msg.getFrom(), msg.getBody());

            ObjectMapper mapper = new ObjectMapper();
            mapper.setDateFormat(new SimpleDateFormat("dd-MM-yyyy HH:mm"));

            // Construct message
            UserSessionMessageImpl message = mapper.readValue(msg.getBody(), UserSessionMessageImpl.class);
            message.setFrom(msg.getFrom());

            if (subscriber != null) {
                subscriber.messageReceived(message);
                logger.debug("Notified subscriber => {}", subscriber);
            }

        }
    } catch (Exception e) {
        logger.error(e.getMessage(), e);
    }
}
项目:lider    文件:MissingPluginListener.java   
@Override
public void processPacket(Stanza packet) throws NotConnectedException {
    try {
        if (packet instanceof Message) {

            Message msg = (Message) packet;
            logger.info("Missing plugin message received from => {}, body => {}", msg.getFrom(), msg.getBody());

            ObjectMapper mapper = new ObjectMapper();
            mapper.setDateFormat(new SimpleDateFormat("dd-MM-yyyy HH:mm"));

            // Construct message
            MissingPluginMessageImpl message = mapper.readValue(msg.getBody(), MissingPluginMessageImpl.class);
            message.setFrom(msg.getFrom());

            if (subscriber != null) {
                ILiderMessage response = subscriber.messageReceived(message);
                logger.debug("Notified subscriber => {}", subscriber);
                client.sendMessage(new ObjectMapper().writeValueAsString(response), msg.getFrom());
            }

        }
    } catch (Exception e) {
        logger.error(e.getMessage(), e);
    }
}
项目:lider    文件:AgreementStatusListener.java   
@Override
public void processPacket(Stanza packet) throws NotConnectedException {
    try {
        if (packet instanceof Message) {

            Message msg = (Message) packet;
            logger.info("Agreement status message received from => {}, body => {}", msg.getFrom(), msg.getBody());

            ObjectMapper mapper = new ObjectMapper();
            mapper.setDateFormat(new SimpleDateFormat("dd-MM-yyyy HH:mm"));

            // Construct message
            AgreementStatusMessageImpl message = mapper.readValue(msg.getBody(), AgreementStatusMessageImpl.class);
            message.setFrom(msg.getFrom());

            if (subscriber != null) {
                subscriber.messageReceived(message);
                logger.debug("Notified subscriber => {}", subscriber);
            }
        }
    } catch (Exception e) {
        logger.error(e.getMessage(), e);
    }
}
项目:lider    文件:ScriptResultListener.java   
@Override
public void processPacket(Stanza packet) throws NotConnectedException {
    try {
        if (packet instanceof Message) {

            Message msg = (Message) packet;
            logger.info("Script result message received from => {}, body => {}", msg.getFrom(), msg.getBody());

            ObjectMapper mapper = new ObjectMapper();
            mapper.setDateFormat(new SimpleDateFormat("dd-MM-yyyy HH:mm"));

            // Construct message
            ScriptResultMessageImpl message = mapper.readValue(msg.getBody(), ScriptResultMessageImpl.class);
            message.setFrom(msg.getFrom());

            if (subscriber != null) {
                subscriber.messageReceived(message);
                logger.debug("Notified subscriber => {}", subscriber);
            }
        }
    } catch (Exception e) {
        logger.error(e.getMessage(), e);
    }
}
项目:communote-server    文件:XMPPMessagePacketListener.java   
/**
 * This method checks if the user is out of the flooding interval. If the user is in the
 * interval he will get a message.
 *
 * @param message
 *            The message to extract the user from.
 * @param alias
 *            Alias to send an information message if user is within his time border.
 * @return true if the user is able to send a message.
 * @throws NotConnectedException
 */
private boolean checkUserTimeBorder(Message message, AliasPacketExtension alias)
        throws NotConnectedException {
    String key = getUserTimeMapKey(message);
    if (timeMap.containsKey(key)) {
        if (!((System.currentTimeMillis() - timeMap.get(key)) > XMPPConnector.getTimeToWait())) {
            sendMessage(
                    message.getFrom(),
                    message.getTo(),
                    alias.getValue(),
                    ResourceBundleManager.instance().getText(
                            "xmpp.message.wait",
                            XMPPPatternUtils.extractKenmeiUser(message.getFrom())
                                    .getLanguageLocale(),
                            Math.round(XMPPConnector.getTimeToWait() / 1000)));
            return false;
        }
    }
    return true;
}
项目:Smack    文件:XHTMLExtensionTest.java   
/**
    * Low level API test.
    * This is a simple test to use with an XMPP client and check if the client receives the message
    * 1. User_1 will send a message with formatted text (XHTML) to user_2
    */
   public void testSendSimpleXHTMLMessage() {
// User1 creates a chat with user2
Chat chat1 = getConnection(0).getChatManager().createChat(getBareJID(1), null);

// User1 creates a message to send to user2
Message msg = new Message();
msg.setSubject("Any subject you want");
msg.setBody("Hey John, this is my new green!!!!");
// Create a XHTMLExtension Package and add it to the message
XHTMLExtension xhtmlExtension = new XHTMLExtension();
xhtmlExtension.addBody(
"<body><p style='font-size:large'>Hey John, this is my new <span style='color:green'>green</span><em>!!!!</em></p></body>");
msg.addExtension(xhtmlExtension);

// User1 sends the message that contains the XHTML to user2
try {
    chat1.sendMessage(msg);
    Thread.sleep(200);
}
catch (Exception e) {
    fail("An error occured sending the message with XHTML");
}
   }
项目:Smack    文件:MultiUserChatManager.java   
private MultiUserChatManager(XMPPConnection connection) {
    super(connection);
    // Listens for all messages that include a MUCUser extension and fire the invitation
    // listeners if the message includes an invitation.
    StanzaListener invitationPacketListener = new StanzaListener() {
        public void processPacket(Stanza packet) {
            final Message message = (Message) packet;
            // Get the MUCUser extension
            final MUCUser mucUser = MUCUser.from(message);
            // Check if the MUCUser extension includes an invitation
            if (mucUser.getInvite() != null) {
                // Fire event for invitation listeners
                final MultiUserChat muc = getMultiUserChat(packet.getFrom());
                for (final InvitationListener listener : invitationsListeners) {
                    listener.invitationReceived(connection(), muc, mucUser.getInvite().getFrom(),
                                    mucUser.getInvite().getReason(), mucUser.getPassword(), message);
                }
            }
        }
    };
    connection.addAsyncStanzaListener(invitationPacketListener, INVITATION_FILTER);
}
项目:jmeter-bzm-plugins    文件:NoOp.java   
@Override
public SampleResult perform(JMeterXMPPSampler sampler, SampleResult res) throws Exception {
    long counter = 0;
    for (Packet packet : incomingPackets) {
        incomingPackets.remove(packet);
        SampleResult subRes = new SampleResult();
        subRes.setSuccessful(true);
        subRes.setResponseCode("200");
        subRes.setResponseMessage("OK");
        subRes.setSampleLabel(packet.getClass().getSimpleName().isEmpty() ? packet.getClass().getName() : packet.getClass().getSimpleName());
        subRes.setResponseData(packet.toXML().toString().getBytes());

        if ((packet instanceof Presence) && (((Presence) packet).getType() == Presence.Type.error)) {
            subRes.setSuccessful(false);
            subRes.setResponseCode("500");
            subRes.setResponseMessage(packet.getError().toString());
        } else if ((packet instanceof Message) && (((Message) packet).getType() == Message.Type.error)) {
            subRes.setSuccessful(false);
            subRes.setResponseCode("500");
            subRes.setResponseMessage(packet.getError().toString());
        } else if ((packet instanceof IQ) && (((IQ) packet).getType() == IQ.Type.error)) {
            subRes.setSuccessful(false);
            subRes.setResponseCode("500");
            subRes.setResponseMessage(packet.getError().toString());
        }

        res.addSubResult(subRes);
        counter++;
    }
    res.setResponseData(("Received packets: " + counter).getBytes());
    return counter > 0 ? res : null;
}
项目:jmeter-bzm-plugins    文件:SendMessage.java   
@Override
public void setGuiFieldsFromSampler(JMeterXMPPSampler sampler) {
    msgRecipient.setText(sampler.getPropertyAsString(RECIPIENT));
    msgBody.setText(sampler.getPropertyAsString(BODY));
    waitResponse.setSelected(sampler.getPropertyAsBoolean(WAIT_RESPONSE));
    msgType.setSelectedItem(Message.Type.fromString(sampler.getPropertyAsString(TYPE, Message.Type.normal.toString())));
}
项目:jmeter-bzm-plugins    文件:SendMessage.java   
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);
    }
}
项目:VASSAL-src    文件:JabberClient.java   
public void processPacket(Packet packet) {
  Message m = (Message) packet;
  if (ROOM_CHANGE_ACTION.equals(m.getBody())) {
    String jid = getAbsolutePlayerJID(packet.getFrom());
    playerMgr.getPlayer(getAbsolutePlayerJID(packet.getFrom()));
    sendRoomQuery(jid);
  }
}
项目:VASSAL-src    文件:JabberClient.java   
protected boolean acceptPacket(Packet packet) {
  if (chatFilter.accept(packet)) {
    return true;
  }
  if (serverMessageFilter.accept(packet)) {
    return ((Message) packet).getFrom().equals(JabberClient.this.getConnection().getHost());
  }
  return false;
}