Package com.calclab.emite.core.stanzas

Examples of com.calclab.emite.core.stanzas.Presence


    }
  }
 
  @Override
  public final void onPresenceReceived(final PresenceReceivedEvent event) {
    final Presence presence = event.getPresence();
    final RoomChat chat = getRoom(presence.getFrom());
    if (chat != null) {
      chat.receivePresence(presence);
    }
  }
View Full Code Here


  @Test
  public void managerShouldListenPresenceWithPhoto() {
    final HashPresenceReceivedTestHandler handler = new HashPresenceReceivedTestHandler();
    avatarManager.addHashPresenceReceviedHandler(handler);
    final Presence presence = new Presence();
    presence.setFrom(uri("juliet@capulet.com/balcony"));
    presence.getXML().addChild("x", "vcard-temp:x:update").setChildText("photo", "sha1-hash-of-image");
    session.receives(presence);
    assertTrue(handler.isCalledOnce());
    assertEquals(presence, handler.getLastPresence());
  }
View Full Code Here

    final XMLPacket stanza = XMLBuilder.fromXML(received);
    final String name = stanza.getTagName();
    if (name.equals("message")) {
      eventBus.fireEvent(new MessageReceivedEvent(new Message(stanza)));
    } else if (name.equals("presence")) {
      eventBus.fireEvent(new PresenceReceivedEvent(new Presence(stanza)));
    } else if (name.equals("iq")) {
      eventBus.fireEvent(new IQReceivedEvent(new IQ(stanza)));
    } else
      throw new RuntimeException("WHAT IS THIS? (" + name + "): " + stanza.toString());
View Full Code Here

  }

  @Override
  public void onSessionStatusChanged(final SessionStatusChangedEvent event) {
    if (SessionStatus.rosterReady.equals(event.getStatus())) {
      final Presence initialPresence = ownPresence != INITIAL_PRESENCE ? ownPresence : new Presence((Presence.Type)null);
      session.send(initialPresence);
      setOwnPresence(initialPresence);
      session.setStatus(SessionStatus.ready);
    } else if (SessionStatus.loggingOut.equals(event.getStatus())) {
      sendUnavailablePresence(session.getCurrentUserURI());
View Full Code Here

    }
  }

  @Override
  public void onPresenceReceived(final PresenceReceivedEvent event) {
    final Presence presence = event.getPresence();
    if (Presence.Type.probe.equals(presence.getType())) {
      session.send(ownPresence);
    }
  }
View Full Code Here

   * available).
   *
   * @param userURI
   */
  private void sendUnavailablePresence(final XmppURI userURI) {
    final Presence presence = new Presence(Presence.Type.unavailable);
    session.send(presence);
    setOwnPresence(presence);
  }
View Full Code Here

    session.send(presence);
    setOwnPresence(presence);
  }

  private void setOwnPresence(final Presence presence) {
    final Presence oldPresence = ownPresence;
    ownPresence = presence;
    eventBus.fireEventFromSource(new OwnPresenceChangedEvent(oldPresence, presence), this);
  }
View Full Code Here

    session.addPresenceReceivedHandler(this);
  }

  @Override
  public void onPresenceReceived(final PresenceReceivedEvent event) {
    final Presence presence = event.getPresence();
    if (presence.getXML().hasChild("x", "vcard-temp:x:update")) {
      eventBus.fireEventFromSource(new HashPresenceReceivedEvent(presence), this);
    }
  }
View Full Code Here

    session.send(createEnterPresence(historyOptions));
  }

  public void close(final String exitStatus) {
    if (RoomStatus.ready.equals(status)) {
      final Presence exitPresence = new Presence(Presence.Type.unavailable, roomUri);
      if (exitStatus != null) {
        exitPresence.setStatus(exitStatus);
      }
      session.send(exitPresence);
    }
  }
View Full Code Here

   *
   * @param statusMessage
   * @param show
   */
  public void setStatus(final String statusMessage, final Presence.Show show) {
    final Presence presence = new Presence();
    presence.setStatus(statusMessage);
    presence.setShow(show);
    presence.setTo(roomUri);
    // presence.addChild("x", XmppNamespaces.MUC);
    // presence.setPriority(0);
    session.send(presence);
  }
View Full Code Here

TOP

Related Classes of com.calclab.emite.core.stanzas.Presence

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.