Java 类org.jivesoftware.smack.ChatManagerListener 实例源码

项目:SmackDemo    文件:MainActivity.java   
private void initState() {
    getSupportActionBar().setTitle(XMPPManager.getInstance().getState().getMessage());
    chatManager = ChatManager.getInstanceFor(XMPPManager.getInstance().connection);
    chatManager.addChatListener(new ChatManagerListener() {
        @Override
        public void chatCreated(Chat chat, boolean createdLocally) {
            if (createdLocally) {
               // Chat created by myself
            } else {
               // Chat created by others
                chat.addMessageListener(chatMessageListener);
            }

        }
    });

    if (!TextUtils.isEmpty(username)) {
        chat = chatManager.createChat(username + "@" + XMPPManager.serverName, chatMessageListener);
    }

}
项目:AyoSunny    文件:MsfService.java   
/**
 * 初始化XMPP
 */
void initXMPP() {
    mXMPPConnection = mXmppConnectionManager.init();                        //初始化XMPPConnection
    loginXMPP();                                                            //登录XMPP
    ChatManager chatmanager = mXMPPConnection.getChatManager();
    chatmanager.addChatListener(new ChatManagerListener() {
        @Override
        public void chatCreated(Chat arg0, boolean arg1) {
            arg0.addMessageListener(new MsgListener(MsfService.this, mNotificationManager));
        }
    });
}
项目:visual-programming    文件:XmppAgent.java   
public void connect() {
    try {

        ConnectionConfiguration config = new ConnectionConfiguration(server, 5222);
        config.setCompressionEnabled(true);
        config.setSASLAuthenticationEnabled(true);
        config.setReconnectionAllowed(true);


        connection = new XMPPConnection(config);

        connection.connect();

        connection.login(username, password);

        final ChatManager chatManager = connection.getChatManager();
        chatManager.addChatListener(new ChatManagerListener() {

            @Override
            public void chatCreated(Chat chat, boolean createdLocally) {
                chat.addMessageListener(getMessageListener());

            }
        });
    } catch (XMPPException e) {

        throw new RuntimeException(e);
    }
}