use of org.jivesoftware.smack.XMPPException in project openhab1-addons by openhab.
the class XMPP method chatXMPP.
/**
* Sends a message to an XMPP multi user chat.
*
* @param message the message to send
*
* @return <code>true</code>, if sending the message has been successful and
* <code>false</code> in all other cases.
*/
@ActionDoc(text = "Sends a message to an XMPP multi user chat.")
public static boolean chatXMPP(@ParamDoc(name = "message") String message) {
boolean success = false;
try {
MultiUserChat chat = XMPPConnect.getChat();
try {
while (message.length() >= 2000) {
chat.sendMessage(message.substring(0, 2000));
message = message.substring(2000);
}
chat.sendMessage(message);
logger.debug("Sent message '{}' to multi user chat.", message);
success = true;
} catch (XMPPException e) {
logger.warn("Error Delivering block", e);
} catch (NotConnectedException e) {
logger.warn("Error Delivering block", e);
}
} catch (NotInitializedException e) {
logger.warn("Could not send XMPP message as connection is not correctly initialized!");
}
return success;
}
use of org.jivesoftware.smack.XMPPException in project intellij-plugins by JetBrains.
the class JabberFacade_ConnectionTest method suite.
public static Test suite() {
TestSuite testSuite = new TestSuite();
XMPPConnection ourConnection;
try {
ourConnection = new XMPPConnection(LOCALHOST);
} catch (XMPPException e) {
return testSuite;
}
ourConnection.close();
testSuite.addTestSuite(JabberFacade_ConnectionTest.class);
return testSuite;
}
Aggregations