Quantcast
Channel: Ignite Realtime: Message List
Viewing all articles
Browse latest Browse all 11413

Re: In Multi User Chat notification about kick event

$
0
0

Hi, the follwing docs may help you

 

http://xmpp.org/extensions/xep-0045.html

8.2 Kicking an Occupant

After informing the moderator, the service MUST then inform all of the remaining occupants that the kicked occupant is no longer in the room by sending presence stanzas of type "unavailable" from the individual's roomnick (<room@service/nick>) to all the remaining occupants (just as it does when occupants exit the room of their own volition), including the status code and optionally the reason and actor.

 

here is my code

1:banUser

2:send presence to other members in this MultiUserChat

 

public boolean banUser(IMMUCBean mucBean , MultiUserChat muc , String memberJid){

                    boolean result = true;

                    try {

                              muc.banUser(memberJid, null);

 

                              MUCUser.Status status = new MUCUser.Status("301");

                              String from = mucBean.getId()+"/"+sConnection.getUser();

                              MUCUser mucUser = new MUCUser();

                              MUCUser.Item item = new MUCUser.Item("outcast", "none");

                              item.setJid(memberJid);

                              item.setActor(StringUtils.parseBareAddress(sConnection.getUser() ));

                              mucUser.setItem(item);

                              mucUser.setStatus(status);

 

                              List<IMFriendBean> members = mucBean.getEntities();

                              for(IMFriendBean member:members){

                                        if(member.getId().equals(memberJid))//不再对被踢者发送了

                                                  continue;

                                        Presence presence = new Presence(Presence.Type.unavailable);

                                        presence.addExtension(mucUser);

                                        presence.setFrom(from);

                                        presence.setTo(member.getId());

                                        LogUtils.e(tag, "踢人 对外presence:"+presence.toXML());

                                        sConnection.sendPacket(presence);

                              }

 

                    } catch (XMPPException e) {

                              LogUtils.e(tag, "ban user failed...");

                              result = false;

                    }

                    return result;

          }

 



Viewing all articles
Browse latest Browse all 11413

Trending Articles