Examples of IMException


Examples of org.wso2.carbon.mashup.imwrapper.core.IMException

                log.error(e);
            }
        } while (!loginProcessed);

        if (!loggedIn) {
            throw new IMException(errorMessage);
        }
    }
View Full Code Here

Examples of org.wso2.carbon.mashup.imwrapper.core.IMException

        }
    }

    public void sendMessage(String to, String message) throws IMException {
        if (disconnectCalled) {
            throw new IMException("Unable to send message cause the IM connection is been " +
                    "disconnected");
        }
        if (loginProcessed && loggedIn) {
            final Email email = Email.parseStr(to);
            final String text = message;
            messageCount ++;
            MsnSwitchboard[] switchboards = messenger.getActiveSwitchboards();
            for (MsnSwitchboard switchboard1 : switchboards) {
                if (switchboard1.containContact(email)
                        && switchboard1.getAllContacts().length == 1) {
                    switchboard1.sendText(text);
                    messageCount--;
                    return;
                }
            }

            final Object attachment = new Object();
            messenger.addSwitchboardListener(new MsnSwitchboardAdapter() {

                public void switchboardStarted(MsnSwitchboard switchboard) {
                    if (switchboard.getAttachment() == attachment) {
                        switchboard.inviteContact(email);
                    }
                }

                public void contactJoinSwitchboard(MsnSwitchboard switchboard,
                                                   MsnContact contact) {
                    if (switchboard.getAttachment() == attachment
                            && email.equals(contact.getEmail())) {
                        switchboard.setAttachment(null);
                        messenger.removeSwitchboardListener(this);
                        switchboard.sendText(text);
                        messageCount --;
                    }
                }

            });
            messenger.newSwitchboard(attachment);
        } else {
            log.error("Got to Log in before a message can be sent.");
            throw new IMException("Got to Log in before a message can be sent.");
        }
    }
View Full Code Here

Examples of org.wso2.carbon.mashup.imwrapper.core.IMException

            loggedIn = false;

            // If there were unsent messgaes, probably the messages were sent to non-existing users
            // we throw an exception after disconnection
            if (messageCount > 0) {
                throw new IMException(
                        "There are some messages that were not sent to MSN recipients. " +
                                "The reason could be that these recipients were not online. " +
                                messageCount + " messages were not delivered");
            }
        } else {
            log.error("Cannot disconnect cause the connection is not made as yet");
            throw new IMException("Cannot disconnect cause the connection is not made as yet");
        }
    }
View Full Code Here

Examples of org.wso2.carbon.mashup.imwrapper.core.IMException

    public void login(String userID, String password) throws IMException {
        int index = userID.indexOf("@");
        if (index < 1 || userID.length() == (index + 1)) {
            log.error(
                    "The format of the userID is incorrect. The userID must be of the form userName@jabberServer");
            throw new IMException(
                    "The format of the userID is incorrect. The userID must be of the form userName@jabberServer");
        }
        String username = userID.substring(0, index);
        String serverName = userID.substring(index + 1);
        connection = new XMPPConnection(serverName);
        try {
            connection.connect();
            connection.login(username, password);
        } catch (XMPPException e) {
            loginProcessed = true;
            loggedIn = false;
            log.error(e);
            throw new IMException(e);
        }
        loginProcessed = true;
        loggedIn = true;
    }
View Full Code Here

Examples of org.wso2.carbon.mashup.imwrapper.core.IMException

            chatMessage.setBody(message);
            chatMessage.setType(Message.Type.normal);
            connection.sendPacket(chatMessage);
        } else {
            log.error("Got to Log in before a message can be sent.");
            throw new IMException("Got to Log in before a message can be sent.");
        }
    }
View Full Code Here

Examples of org.wso2.carbon.mashup.imwrapper.core.IMException

            if (log.isDebugEnabled()) {
                log.debug("Connection to jabber server disconnected");
            }
        } else {
            log.error("Cannot disconnect cause the connection is not made as yet");
            throw new IMException("Cannot disconnect cause the connection is not made as yet");
        }
    }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.