• 如果您觉得本站非常有看点,那么赶紧使用Ctrl+D 收藏吧

Java OccupantAddedEvent类的典型用法和代码示例

java 2次浏览

本文整理汇总了Java中org.jivesoftware.openfire.muc.cluster.OccupantAddedEvent的典型用法代码示例。如果您正苦于以下问题:Java OccupantAddedEvent类的具体用法?Java OccupantAddedEvent怎么用?Java OccupantAddedEvent使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。

OccupantAddedEvent类属于org.jivesoftware.openfire.muc.cluster包,在下文中一共展示了OccupantAddedEvent类的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。

示例1: joinedCluster

点赞 3

import org.jivesoftware.openfire.muc.cluster.OccupantAddedEvent; //导入依赖的package包/类
@Override
@SuppressWarnings("unchecked")
public void joinedCluster(byte[] nodeID) {
    Object result = CacheFactory.doSynchronousClusterTask(new GetNewMemberRoomsRequest(), nodeID);
    if (result instanceof List<?>) {
        List<RoomInfo> rooms = (List<RoomInfo>) result;
        for (RoomInfo roomInfo : rooms) {
            LocalMUCRoom remoteRoom = roomInfo.getRoom();
            MultiUserChatServiceImpl service = (MultiUserChatServiceImpl)remoteRoom.getMUCService();
            LocalMUCRoom localRoom = service.getLocalChatRoom(remoteRoom.getName());
            if (localRoom == null) {
                // Create local room with remote information
                localRoom = remoteRoom;
                service.chatRoomAdded(localRoom);
            }
            // Add remote occupants to local room
            for (OccupantAddedEvent event : roomInfo.getOccupants()) {
                event.setSendPresence(true);
                event.run();
            }
        }
    }
}
 

开发者ID:igniterealtime,
项目名称:Openfire,
代码行数:24,
代码来源:MultiUserChatManager.java

示例2: joinedCluster

点赞 3

import org.jivesoftware.openfire.muc.cluster.OccupantAddedEvent; //导入依赖的package包/类
public void joinedCluster(byte[] nodeID) {
    @SuppressWarnings("unchecked")
    List<RoomInfo> result =
            (List<RoomInfo>) CacheFactory.doSynchronousClusterTask(new GetNewMemberRoomsRequest(), nodeID);
    if (result != null) {
        for (RoomInfo roomInfo : result) {
            LocalMUCRoom remoteRoom = roomInfo.getRoom();
            MultiUserChatServiceImpl service = (MultiUserChatServiceImpl)remoteRoom.getMUCService();
            LocalMUCRoom localRoom = service.getLocalChatRoom(remoteRoom.getName());
            if (localRoom == null) {
                // Create local room with remote information
                localRoom = remoteRoom;
                service.chatRoomAdded(localRoom);
            }
            // Add remote occupants to local room
            for (OccupantAddedEvent event : roomInfo.getOccupants()) {
                event.setSendPresence(true);
                event.run();
            }
        }
    }
}
 

开发者ID:coodeer,
项目名称:g3server,
代码行数:23,
代码来源:MultiUserChatManager.java

示例3: joinedCluster

点赞 3

import org.jivesoftware.openfire.muc.cluster.OccupantAddedEvent; //导入依赖的package包/类
@SuppressWarnings("unchecked")
public void joinedCluster(byte[] nodeID) {
    Object result = CacheFactory.doSynchronousClusterTask(new GetNewMemberRoomsRequest(), nodeID);
    if (result instanceof List<?>) {
        List<RoomInfo> rooms = (List<RoomInfo>) result;
        for (RoomInfo roomInfo : rooms) {
            LocalMUCRoom remoteRoom = roomInfo.getRoom();
            MultiUserChatServiceImpl service = (MultiUserChatServiceImpl)remoteRoom.getMUCService();
            LocalMUCRoom localRoom = service.getLocalChatRoom(remoteRoom.getName());
            if (localRoom == null) {
                // Create local room with remote information
                localRoom = remoteRoom;
                service.chatRoomAdded(localRoom);
            }
            // Add remote occupants to local room
            for (OccupantAddedEvent event : roomInfo.getOccupants()) {
                event.setSendPresence(true);
                event.run();
            }
        }
    }
}
 

开发者ID:idwanglu2010,
项目名称:openfire,
代码行数:23,
代码来源:MultiUserChatManager.java

示例4: RemoteMUCRole

点赞 2

import org.jivesoftware.openfire.muc.cluster.OccupantAddedEvent; //导入依赖的package包/类
public RemoteMUCRole(MultiUserChatService server, OccupantAddedEvent event) {
    this.serviceDomain = server.getServiceDomain();
    presence = event.getPresence();
    role = event.getRole();
    affiliation = event.getAffiliation();
    nickname = event.getNickname();
    voiceOnly = event.isVoiceOnly();
    roleAddress = event.getRoleAddress();
    userAddress = event.getUserAddress();
    room = event.getRoom();
    this.nodeID = event.getNodeID();
}
 

开发者ID:igniterealtime,
项目名称:Openfire,
代码行数:13,
代码来源:RemoteMUCRole.java

示例5: occupantAdded

点赞 2

import org.jivesoftware.openfire.muc.cluster.OccupantAddedEvent; //导入依赖的package包/类
public void occupantAdded(OccupantAddedEvent event) {
    // Do not add new occupant with one with same nickname already exists
    if (occupants.containsKey(event.getNickname().toLowerCase())) {
        // TODO Handle conflict of nicknames
        return;
    }
    // Create a proxy for the occupant that joined the room from another cluster node
    RemoteMUCRole joinRole = new RemoteMUCRole(mucService, event);
    // Add the new user as an occupant of this room
    occupants.put(event.getNickname().toLowerCase(), joinRole);
    // Update the tables of occupants based on the bare and full JID
    List<MUCRole> list = occupantsByBareJID.get(event.getUserAddress().toBareJID());
    if (list == null) {
        list = new ArrayList<MUCRole>();
        occupantsByBareJID.put(event.getUserAddress().toBareJID(), list);
    }
    list.add(joinRole);
    occupantsByFullJID.put(event.getUserAddress(), joinRole);

    // Update the date when the last occupant left the room
    setEmptyDate(null);
    if (event.isOriginator()) {
        // Fire event that occupant joined the room
        MUCEventDispatcher.occupantJoined(getRole().getRoleAddress(), event.getUserAddress(), joinRole.getNickname());
    }
    // Check if we need to send presences of the new occupant to occupants hosted by this JVM
    if (event.isSendPresence()) {
        for (MUCRole occupant : occupants.values()) {
            if (occupant.isLocal()) {
                occupant.send(event.getPresence().createCopy());
            }
        }
    }
}
 

开发者ID:coodeer,
项目名称:g3server,
代码行数:35,
代码来源:LocalMUCRoom.java

示例6: occupantAdded

点赞 2

import org.jivesoftware.openfire.muc.cluster.OccupantAddedEvent; //导入依赖的package包/类
public void occupantAdded(OccupantAddedEvent event) {
      // Do not add new occupant with one with same nickname already exists
      if (occupants.containsKey(event.getNickname().toLowerCase())) {
          // TODO Handle conflict of nicknames
          return;
      }
      // Create a proxy for the occupant that joined the room from another cluster node
      RemoteMUCRole joinRole = new RemoteMUCRole(mucService, event);
      // Add the new user as an occupant of this room
      occupants.put(event.getNickname().toLowerCase(), joinRole);
      // Update the tables of occupants based on the bare and full JID
      JID bareJID = new JID(event.getUserAddress().toBareJID());
List<MUCRole> list = occupantsByBareJID.get(bareJID);
      if (list == null) {
          list = new ArrayList<MUCRole>();
          occupantsByBareJID.put(bareJID, list);
      }
      list.add(joinRole);
      occupantsByFullJID.put(event.getUserAddress(), joinRole);

      // Update the date when the last occupant left the room
      setEmptyDate(null);
      if (event.isOriginator()) {
          // Fire event that occupant joined the room
          MUCEventDispatcher.occupantJoined(getRole().getRoleAddress(), event.getUserAddress(), joinRole.getNickname());
      }
      // Check if we need to send presences of the new occupant to occupants hosted by this JVM
      if (event.isSendPresence()) {
          for (MUCRole occupant : occupants.values()) {
              if (occupant.isLocal()) {
                  occupant.send(event.getPresence().createCopy());
              }
          }
      }
  }
 

开发者ID:surevine,
项目名称:openfire-bespoke,
代码行数:36,
代码来源:LocalMUCRoom.java

示例7: getChatRoom

点赞 2

import org.jivesoftware.openfire.muc.cluster.OccupantAddedEvent; //导入依赖的package包/类
@Override
public MUCRoom getChatRoom(String roomName, JID userjid) throws NotAllowedException {
    LocalMUCRoom room;
    boolean loaded = false;
    boolean created = false;
    synchronized (roomName.intern()) {
        room = localMUCRoomManager.getRoom(roomName);
        if (room == null) {
            room = new LocalMUCRoom(this, roomName, router);
            // If the room is persistent load the configuration values from the DB
            try {
                // Try to load the room's configuration from the database (if the room is
                // persistent but was added to the DB after the server was started up or the
                // room may be an old room that was not present in memory)
                MUCPersistenceManager.loadFromDB(room);
                loaded = true;
            }
            catch (IllegalArgumentException e) {
                // Check if room needs to be recreated in case it failed to be created previously
                // (or was deleted somehow and is expected to exist by a delegate).
                if (mucEventDelegate != null && mucEventDelegate.shouldRecreate(roomName, userjid)) {
                    if (mucEventDelegate.loadConfig(room)) {
                        loaded = true;
                        if (room.isPersistent()) {
                            MUCPersistenceManager.saveToDB(room);
                        }
                    }
                    else {
                        // Room does not exist and delegate does not recognize it and does
                        // not allow room creation
                        throw new NotAllowedException();

                    }
                }
                else {
                    // The room does not exist so check for creation permissions
                    // Room creation is always allowed for sysadmin
                    final JID bareJID = userjid.asBareJID();
                    if (isRoomCreationRestricted() && !sysadmins.includes(bareJID)) {
                        // The room creation is only allowed for certain JIDs
                        if (!allowedToCreate.includes(bareJID)) {
                            // The user is not in the list of allowed JIDs to create a room so raise
                            // an exception
                            throw new NotAllowedException();
                        }
                    }
                    room.addFirstOwner(userjid);
                    created = true;
                }
            }
            localMUCRoomManager.addRoom(roomName, room);
        }
    }
    if (created) {
        // Fire event that a new room has been created
        MUCEventDispatcher.roomCreated(room.getRole().getRoleAddress());
    }
    if (loaded || created) {
        // Notify other cluster nodes that a new room is available
        CacheFactory.doClusterTask(new RoomAvailableEvent(room));
        for (MUCRole role : room.getOccupants()) {
            if (role instanceof LocalMUCRole) {
                CacheFactory.doClusterTask(new OccupantAddedEvent(room, role));
            }
        }
    }
    return room;
}
 

开发者ID:igniterealtime,
项目名称:Openfire,
代码行数:69,
代码来源:MultiUserChatServiceImpl.java

示例8: occupantAdded

点赞 2

import org.jivesoftware.openfire.muc.cluster.OccupantAddedEvent; //导入依赖的package包/类
public void occupantAdded(OccupantAddedEvent event) {
    // Create a proxy for the occupant that joined the room from another cluster node
    RemoteMUCRole joinRole = new RemoteMUCRole(mucService, event);
    JID bareJID = event.getUserAddress().asBareJID();
    String nickname = event.getNickname();
    List<MUCRole> occupants = occupantsByNickname.get(nickname.toLowerCase());
    // Do not add new occupant with one with same nickname already exists
    if (occupants == null) {
        occupants = new ArrayList<>();
        occupantsByNickname.put(nickname.toLowerCase(), occupants);
    } else {
        // sanity check; make sure the nickname is owned by the same JID
        if (occupants.size() > 0) {
            JID existingJID = occupants.get(0).getUserAddress().asBareJID();
            if (!bareJID.equals(existingJID)) {
                Log.warn(MessageFormat.format("Conflict detected; {0} requested nickname '{1}'; already being used by {2}", bareJID, nickname, existingJID));
                return;
            }
        }
    }
    // Add the new user as an occupant of this room
    occupants.add(joinRole);
    // Update the tables of occupants based on the bare and full JID
    List<MUCRole> list = occupantsByBareJID.get(bareJID);
    if (list == null) {
        list = new ArrayList<>();
        occupantsByBareJID.put(bareJID, list);
    }
    list.add(joinRole);
    occupantsByFullJID.put(event.getUserAddress(), joinRole);

    // Update the date when the last occupant left the room
    setEmptyDate(null);
    if (event.isOriginator()) {
        // Fire event that occupant joined the room
        MUCEventDispatcher.occupantJoined(getRole().getRoleAddress(), event.getUserAddress(), joinRole.getNickname());
    }
    // Check if we need to send presences of the new occupant to occupants hosted by this JVM
    if (event.isSendPresence()) {
        for (MUCRole occupant : occupantsByFullJID.values()) {
            if (occupant.isLocal()) {
                occupant.send(event.getPresence().createCopy());
            }
        }
    }
}
 

开发者ID:igniterealtime,
项目名称:Openfire,
代码行数:47,
代码来源:LocalMUCRoom.java

示例9: getChatRoom

点赞 2

import org.jivesoftware.openfire.muc.cluster.OccupantAddedEvent; //导入依赖的package包/类
public MUCRoom getChatRoom(String roomName, JID userjid) throws NotAllowedException {
    LocalMUCRoom room;
    boolean loaded = false;
    boolean created = false;
    synchronized (roomName.intern()) {
        room = rooms.get(roomName);
        if (room == null) {
            room = new LocalMUCRoom(this, roomName, router);
            // If the room is persistent load the configuration values from the DB
            try {
                // Try to load the room's configuration from the database (if the room is
                // persistent but was added to the DB after the server was started up or the
                // room may be an old room that was not present in memory)
                MUCPersistenceManager.loadFromDB(room);
                loaded = true;
            }
            catch (IllegalArgumentException e) {
                // Check if room needs to be recreated in case it failed to be created previously
                // (or was deleted somehow and is expected to exist by a delegate).
                if (mucEventDelegate != null && mucEventDelegate.shouldRecreate(roomName, userjid)) {
                    if (mucEventDelegate.loadConfig(room)) {
                        loaded = true;
                        if (room.isPersistent()) {
                            MUCPersistenceManager.saveToDB(room);
                        }
                    }
                    else {
                        // Room does not exist and delegate does not recognize it and does
                        // not allow room creation
                        throw new NotAllowedException();

                    }
                }
                else {
                    // The room does not exist so check for creation permissions
                    // Room creation is always allowed for sysadmin
                    if (isRoomCreationRestricted() && !sysadmins.contains(userjid.toBareJID())) {
                        // The room creation is only allowed for certain JIDs
                        if (!allowedToCreate.contains(userjid.toBareJID())) {
                            // The user is not in the list of allowed JIDs to create a room so raise
                            // an exception
                            throw new NotAllowedException();
                        }
                    }
                    room.addFirstOwner(userjid.toBareJID());
                    created = true;
                }
            }
            rooms.put(roomName, room);
        }
    }
    if (created) {
        // Fire event that a new room has been created
        MUCEventDispatcher.roomCreated(room.getRole().getRoleAddress());
    }
    if (loaded || created) {
        // Notify other cluster nodes that a new room is available
        CacheFactory.doClusterTask(new RoomAvailableEvent(room));
        for (MUCRole role : room.getOccupants()) {
            if (role instanceof LocalMUCRole) {
                CacheFactory.doClusterTask(new OccupantAddedEvent(room, role));
            }
        }
    }
    return room;
}
 

开发者ID:coodeer,
项目名称:g3server,
代码行数:67,
代码来源:MultiUserChatServiceImpl.java

示例10: getChatRoom

点赞 2

import org.jivesoftware.openfire.muc.cluster.OccupantAddedEvent; //导入依赖的package包/类
public MUCRoom getChatRoom(String roomName, JID userjid) throws NotAllowedException {
    LocalMUCRoom room;
    boolean loaded = false;
    boolean created = false;
    synchronized (roomName.intern()) {
        room = rooms.get(roomName);
        if (room == null) {
            room = new LocalMUCRoom(this, roomName, router);
            // If the room is persistent load the configuration values from the DB
            try {
                // Try to load the room's configuration from the database (if the room is
                // persistent but was added to the DB after the server was started up or the
                // room may be an old room that was not present in memory)
                MUCPersistenceManager.loadFromDB(room);
                loaded = true;
            }
            catch (IllegalArgumentException e) {
                // Check if room needs to be recreated in case it failed to be created previously
                // (or was deleted somehow and is expected to exist by a delegate).
                if (mucEventDelegate != null && mucEventDelegate.shouldRecreate(roomName, userjid)) {
                    if (mucEventDelegate.loadConfig(room)) {
                        loaded = true;
                        if (room.isPersistent()) {
                            MUCPersistenceManager.saveToDB(room);
                        }
                    }
                    else {
                        // Room does not exist and delegate does not recognize it and does
                        // not allow room creation
                        throw new NotAllowedException();

                    }
                }
                else {
                    // The room does not exist so check for creation permissions
                    // Room creation is always allowed for sysadmin
                    final JID bareJID = userjid.asBareJID();
		if (isRoomCreationRestricted() && !sysadmins.contains(bareJID)) {
                        // The room creation is only allowed for certain JIDs
                        if (!allowedToCreate.contains(bareJID)) {
                            // The user is not in the list of allowed JIDs to create a room so raise
                            // an exception
                            throw new NotAllowedException();
                        }
                    }
                    room.addFirstOwner(userjid);
                    created = true;
                }
            }
            rooms.put(roomName, room);
        }
    }
    if (created) {
        // Fire event that a new room has been created
        MUCEventDispatcher.roomCreated(room.getRole().getRoleAddress());
    }
    if (loaded || created) {
        // Notify other cluster nodes that a new room is available
        CacheFactory.doClusterTask(new RoomAvailableEvent(room));
        for (MUCRole role : room.getOccupants()) {
            if (role instanceof LocalMUCRole) {
                CacheFactory.doClusterTask(new OccupantAddedEvent(room, role));
            }
        }
    }
    return room;
}
 

开发者ID:idwanglu2010,
项目名称:openfire,
代码行数:68,
代码来源:MultiUserChatServiceImpl.java

示例11: occupantAdded

点赞 2

import org.jivesoftware.openfire.muc.cluster.OccupantAddedEvent; //导入依赖的package包/类
public void occupantAdded(OccupantAddedEvent event) {
      // Create a proxy for the occupant that joined the room from another cluster node
      RemoteMUCRole joinRole = new RemoteMUCRole(mucService, event);
      JID bareJID = event.getUserAddress().asBareJID();
      String nickname = event.getNickname();
      List<MUCRole> occupants = occupantsByNickname.get(nickname.toLowerCase());
      // Do not add new occupant with one with same nickname already exists
      if (occupants == null) {
          occupants = new ArrayList<MUCRole>();
          occupantsByNickname.put(nickname.toLowerCase(), occupants);
      } else {
      	// sanity check; make sure the nickname is owned by the same JID
      	if (occupants.size() > 0) {
      		String existingJID = occupants.get(0).getUserAddress().toBareJID();
      		if (!bareJID.equals(existingJID)) {
      			Log.warn(MessageFormat.format("Conflict detected; {0} requested nickname '{1}'; already being used by {2}", bareJID, nickname, existingJID));
      			return;
      		}
      	}
      }
      // Add the new user as an occupant of this room
      occupants.add(joinRole);
      // Update the tables of occupants based on the bare and full JID
List<MUCRole> list = occupantsByBareJID.get(bareJID);
      if (list == null) {
          list = new ArrayList<MUCRole>();
          occupantsByBareJID.put(bareJID, list);
      }
      list.add(joinRole);
      occupantsByFullJID.put(event.getUserAddress(), joinRole);

      // Update the date when the last occupant left the room
      setEmptyDate(null);
      if (event.isOriginator()) {
          // Fire event that occupant joined the room
          MUCEventDispatcher.occupantJoined(getRole().getRoleAddress(), event.getUserAddress(), joinRole.getNickname());
      }
      // Check if we need to send presences of the new occupant to occupants hosted by this JVM
      if (event.isSendPresence()) {
          for (MUCRole occupant : occupantsByFullJID.values()) {
              if (occupant.isLocal()) {
                  occupant.send(event.getPresence().createCopy());
              }
          }
      }
  }
 

开发者ID:idwanglu2010,
项目名称:openfire,
代码行数:47,
代码来源:LocalMUCRoom.java

示例12: getChatRoom

点赞 2

import org.jivesoftware.openfire.muc.cluster.OccupantAddedEvent; //导入依赖的package包/类
public MUCRoom getChatRoom(String roomName, JID userjid) throws NotAllowedException {
    LocalMUCRoom room;
    boolean loaded = false;
    boolean created = false;
    synchronized (roomName.intern()) {
        room = rooms.get(roomName);
        if (room == null) {
            room = new LocalMUCRoom(this, roomName, router);
            // If the room is persistent load the configuration values from the DB
            try {
                // Try to load the room's configuration from the database (if the room is
                // persistent but was added to the DB after the server was started up or the
                // room may be an old room that was not present in memory)
                MUCPersistenceManager.loadFromDB(room);
                loaded = true;
            }
            catch (IllegalArgumentException e) {
                // Check if room needs to be recreated in case it failed to be created previously
                // (or was deleted somehow and is expected to exist by a delegate).
                if (mucEventDelegate != null && mucEventDelegate.shouldRecreate(roomName, userjid)) {
                    if (mucEventDelegate.loadConfig(room)) {
                        loaded = true;
                        if (room.isPersistent()) {
                            MUCPersistenceManager.saveToDB(room);
                        }
                    }
                    else {
                        // Room does not exist and delegate does not recognize it and does
                        // not allow room creation
                        throw new NotAllowedException();

                    }
                }
                else {
                    // The room does not exist so check for creation permissions
                    // Room creation is always allowed for sysadmin
                    final JID bareJID = new JID(userjid.toBareJID());
		if (isRoomCreationRestricted() && !sysadmins.contains(bareJID)) {
                        // The room creation is only allowed for certain JIDs
                        if (!allowedToCreate.contains(bareJID)) {
                            // The user is not in the list of allowed JIDs to create a room so raise
                            // an exception
                            throw new NotAllowedException();
                        }
                    }
                    room.addFirstOwner(userjid);
                    created = true;
                }
            }
            rooms.put(roomName, room);
        }
    }
    if (created) {
        // Fire event that a new room has been created
        MUCEventDispatcher.roomCreated(room.getRole().getRoleAddress());
    }
    if (loaded || created) {
        // Notify other cluster nodes that a new room is available
        CacheFactory.doClusterTask(new RoomAvailableEvent(room));
        for (MUCRole role : room.getOccupants()) {
            if (role instanceof LocalMUCRole) {
                CacheFactory.doClusterTask(new OccupantAddedEvent(room, role));
            }
        }
    }
    return room;
}
 

开发者ID:surevine,
项目名称:openfire-bespoke,
代码行数:68,
代码来源:MultiUserChatServiceImpl.java


版权声明:本文转自网络文章,转载此文章仅为分享知识,如有侵权,请联系管理员进行删除。
喜欢 (0)