protected void doDisconnect() throws Exception { try { if (groupChat != null) { groupChat.leave(); } if (xmppConnection != null) { xmppConnection.close(); } } finally { xmppConnection = null; } }
protected void sendMessage(UMOEvent event) throws Exception { if (chat == null && groupChat == null) { UMOMessage msg = event.getMessage(); boolean group = msg.getBooleanProperty(XmppConnector.XMPP_GROUP_CHAT, false); String nickname = msg.getStringProperty(XmppConnector.XMPP_NICKNAME, "mule"); String recipient = event.getEndpoint().getEndpointURI().getPath().substring(1); if (group) { groupChat = new GroupChat(xmppConnection, recipient); if (!groupChat.isJoined()) { groupChat.join(nickname); } } else { chat = new Chat(xmppConnection, recipient); } } Object msgObj = event.getMessage().getPayload(); Message message; // avoid duplicate transformation if (!(msgObj instanceof Message)) { message = (Message) event.getTransformedMessage(); } else { message = (Message) msgObj; } if (logger.isTraceEnabled()) { logger.trace("Transformed packet: " + message.toXML()); } if (chat != null) { chat.sendMessage(message); } else { groupChat.sendMessage(message); } if (logger.isDebugEnabled()) { logger.debug("Packet successfully sent"); } }
protected UMOMessage doSend(UMOEvent event) throws Exception { sendMessage(event); if (useRemoteSync(event)) { Message response; if (groupChat != null) { response = groupChat.nextMessage(event.getTimeout()); } else { response = chat.nextMessage(event.getTimeout()); } if (response != null) { if (logger.isDebugEnabled()) { logger.debug("Got a response from chat: " + chat); } return new MuleMessage(connector.getMessageAdapter(response)); } } return null; }