Package com.calclab.emite.core.client.xmpp.session

Examples of com.calclab.emite.core.client.xmpp.session.Session


  /*
   * We get the Session object. The most important object of Emite Core
   * module.
   */
  final Session session = Suco.get(Session.class);

  /*
   * We track session state changes. We can only send messages when the
   * state == loggedIn.
   */
  session.onStateChanged(new Listener<Session.State>() {
      public void onEvent(final State state) {
    if (state == Session.State.loggedIn) {
        GWT.log("We are now online", null);
        sendHelloWorldMessage(session);
    } else if (state == Session.State.disconnected) {
        GWT.log("We are now offline", null);
    }
      }
  });

  /*
   * We show every incoming message in the GWT log console
   */
  session.onMessage(new Listener<Message>() {
      public void onEvent(final Message message) {
    GWT.log("Messaged received from " + message.getFrom() + ":" + message.getBody(), null);
      }
  });

  /*
   * We show (log) every incoming presence stanzas
   */
  session.onPresence(new Listener<Presence>() {
      public void onEvent(final Presence presence) {
    GWT.log("Presence received from " + presence.getFrom() + ": " + presence.toString(), null);
      }
  });

  session.login(uri("myJID@myDomain.org"), "myPassword");
    }
View Full Code Here

TOP

Related Classes of com.calclab.emite.core.client.xmpp.session.Session

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.