powered by Jive Software

How to Fetch MUC room occupants list Inside Openfire Plugin?

I am developing a openfire plugin and stuck at one point.

Below is my plugin code. I have implemented MUCEventListener and I am getting callbacks also. But now I want to fetch occupants-list from roomJID in messageReceived() method. research a lot but no success. Please someone get me break through.

public class OfflineMessageTrigger implements Plugin,

MUCEventListener {

private static final Logger Log = LoggerFactory

.getLogger(OfflineMessageTrigger.class);

public OfflineMessageTrigger() {

}

// Plugin Interface

public void initializePlugin(PluginManager manager, File pluginDirectory) {

MUCEventDispatcher.addListener(this);

}

public void destroyPlugin() {

MUCEventDispatcher.removeListener(this);

}

@Override

public void roomCreated(JID roomJID) {

Log.debug("TASOL-OfflineMessageTrigger -> MUC -> roomCreated(): "

  • "RoomID : " + roomJID);

}

@Override

public void roomDestroyed(JID roomJID) {

Log.debug("TASOL-OfflineMessageTrigger -> MUC -> roomDestroyed(): "

  • "RoomID : " + roomJID);

}

@Override

public void occupantJoined(JID roomJID, JID user, String nickname) {

Log.debug("TASOL-OfflineMessageTrigger -> MUC -> occupantJoined(): "

  • "RoomID : " + roomJID + " UserID : " + user + " NickName : "

  • nickname);

}

@Override

public void occupantLeft(JID roomJID, JID user) {

Log.debug("TASOL-OfflineMessageTrigger -> MUC -> occupantLeft(): "

  • "RoomID : " + roomJID + " UserID : " + user);

}

@Override

public void nicknameChanged(JID roomJID, JID user, String oldNickname,

String newNickname) {

}

@Override

public void messageReceived(JID roomJID, JID user, String nickname,

Message message) {

// HERE I WANT TO FETCH OCCUPANTS LIST OF “roomJID”. HOW TO GET?

}

@Override

public void privateMessageRecieved(JID toJID, JID fromJID, Message message) {

}

@Override

public void roomSubjectChanged(JID roomJID, JID user, String newSubject) {

}

}

Thanks

Biraj Zalavadia.

Hello

I just found the way to get occupants. You need to have “roomname” and “jid” to get the occupants list

MultiUserChatService muChatService = XMPPServer.getInstance().getMultiUserChatManager().getMultiUserChatServices().g et(0);

Collection occupants = muChatService.getChatRoom(“roomnamehere”, jid).getOccupants();