Exemplo n.º 1
0
 private Presence enter$324fb5b(String nickname, long timeout)
     throws NotConnectedException, NoResponseException, XMPPErrorException {
   if (StringUtils.isNullOrEmpty(nickname)) {
     throw new IllegalArgumentException("Nickname must not be null or blank.");
   }
   Presence joinPresence = new Presence(Type.available);
   joinPresence.to = this.room + MqttTopic.TOPIC_LEVEL_SEPARATOR + nickname;
   joinPresence.addExtension(new MUCInitialPresence());
   for (PacketInterceptor interceptPacket : this.presenceInterceptors) {
     interceptPacket.interceptPacket(joinPresence);
   }
   PacketCollector response =
       this.connection.createPacketCollector(
           new AndFilter(
               FromMatchesFilter.createFull(
                   this.room + MqttTopic.TOPIC_LEVEL_SEPARATOR + nickname),
               new PacketTypeFilter(Presence.class)));
   this.connection.sendPacket(joinPresence);
   Presence presence = (Presence) response.nextResultOrThrow(timeout);
   this.nickname = nickname;
   this.joined = true;
   List<String> rooms = (List) joinedRooms.get(this.connection);
   if (rooms == null) {
     rooms = new ArrayList();
     joinedRooms.put(this.connection, rooms);
   }
   rooms.add(this.room);
   return presence;
 }
Exemplo n.º 2
0
 private synchronized void leave() throws NotConnectedException {
   if (this.joined) {
     Presence leavePresence = new Presence(Type.unavailable);
     leavePresence.to = this.room + MqttTopic.TOPIC_LEVEL_SEPARATOR + this.nickname;
     for (PacketInterceptor interceptPacket : this.presenceInterceptors) {
       interceptPacket.interceptPacket(leavePresence);
     }
     this.connection.sendPacket(leavePresence);
     this.occupantsMap.clear();
     this.nickname = null;
     this.joined = false;
     userHasLeft();
   }
 }