XMPP室邀请 [英] XMPP Room Invitation

查看:242
本文介绍了XMPP室邀请的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在我的聊天应用程序,我想实现集团聊天功能。出于同样的我要创建房间并发送邀请好友加入房间。这是我的code参加,并邀请朋友到房间。

In my chatting application I want to implement Group Chatting functionality. For the same I want to create rooms and send the invitations to my friends to join the room. Here is my code to join and invite the friend to room.

要创建的房间

//Create Room
    btn_CreateRoom = (Button)findViewById(R.id.btn_usermenu_CreateRoom);
    btn_CreateRoom.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View arg0) {
            // TODO Auto-generated method stub

            try {
                muc = new MultiUserChat(connection, "room1@conference.abc.com");

                muc.join("Sunil","123456");
                muc.sendConfigurationForm(new Form(Form.TYPE_SUBMIT));

            } catch (XMPPException e) {
                // TODO Auto-generated catch block
                e.printStackTrace();
            }

            System.out.println("Room Created");
        }
    });


    btn_Invite = (Button)findViewById(R.id.btn_usermenu_InviteToRoom);
    btn_Invite.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            // TODO Auto-generated method stub


            muc.invite("sunil@abc.com", "Please join this room");



        }
    });

}

要接受她我在服务类中实现的邀请听众的邀请。但我无法通过通知接收投资贸易洽谈会。 WATS与code中的问题。

To recieve the invitation I have implemented an Invitation Listener in my Service Class. But I am unable to receive the invitaion via notification. Wats the problem with the code.

下面是我的邀请监听器。

Here is my Invitation Listener.

MultiUserChat.addInvitationListener(connection, new InvitationListener() {

            @Override
            public void invitationReceived(Connection arg0, String arg1, String arg2,
                    String arg3, String arg4, Message arg5) {
                // TODO Auto-generated method stub

                System.out.println("Received??");
                notification("Invitation Received");

请让我知道为什么我没有收到邀请。??

Please let me know Why I am not receiving the invitation.??

感谢

推荐答案

我们错过了主题这里:

只需添加以下code加入群:

Just add below code to join group:

private void setChatRoomInvitationListener() {
        Thread thread = new Thread(new Runnable() {
            @Override
            public void run() {
                MultiUserChat.addInvitationListener(xmppConnection, new InvitationListener() {
                    @Override
                    public void invitationReceived(Connection connection,String room, String inviter, String reason,String unKnown, Message message) {
                        XMPPConnectionUtils.configureChatStandards();
                        MultiUserChat muc = new MultiUserChat(connection, room);
                        try {
                            muc.join("My_Name_Here");
                        } catch (XMPPException e) {
                            e.printStackTrace();
                        }
                    }
                });
            }
        });
        thread.start();
    }

希望这将有很大的帮助。

Hope this will help a lot.

这篇关于XMPP室邀请的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆