Package org.jivesoftware.smack

Examples of org.jivesoftware.smack.PacketListener


  protected void doDispose() {
    //MUST be called by super controller!
    if (muc != null && muc.isJoined() && connection.isConnected()) {
      try {
        muc.leave();
    PacketListener msgListener = roomJoinTask.getMessageListener();
    if (msgListener != null) muc.removeMessageListener(msgListener);
    PacketListener pListener = roomJoinTask.getParticipationsListener();
    if (pListener != null) muc.removeParticipantListener(pListener);
    muc = null;
      } catch (Exception e) {
        logWarn("Error while leaving multiuserchat:", e);
      }     
View Full Code Here


  /**
   * listens to new messages for this chatroom
   */
  void addMessageListener() {
    messageListener = new PacketListener() {

      public void processPacket(Packet packet) {
        Message jabbmessage = (Message) packet;
        if (log.isDebug()) log.debug("processPacket Msg: to=" + jabbmessage.getTo() );
        jabbmessage.setProperty("receiveTime", new Long(new Date().getTime()));
View Full Code Here

  /**
   * listen to new people joining the room in realtime and and set the new
   * content which sets the component to dirty which forces it to redraw
   */
  void addParticipationsListener() {
    participationsListener = new PacketListener() {

      public void processPacket(Packet packet) {
        Presence presence = (Presence) packet;
        if (log.isDebug()) log.debug("processPacket Presence: to=" + presence.getTo() + " , " );
        if (presence.getFrom() != null) {
View Full Code Here

   * subscribed packet.
   */
  public void addSubscriptionListener() {
    PacketFilter filter = new PacketTypeFilter(Presence.class);
    connection.createPacketCollector(filter);
    PacketListener myListener = new PacketListener() {
      public void processPacket(Packet packet) {
        Presence presence = (Presence) packet;
        if (presence.getType() == Presence.Type.subscribe) {
          Presence response = new Presence(Presence.Type.subscribe);
          response.setTo(presence.getFrom());
View Full Code Here

  /**
   * @param username
   */
  public void addMessageListener(final String username) {
    PacketListener packetListener = new PacketListener() {
      public void processPacket(Packet packet) {
        Message jabbmessage = (Message) packet;
        //TODO:gs:b see issue: http://bugs.olat.org/jira/browse/OLAT-2966
        //filter <script> msg. out - security risk of cross site scripting!
        //or may user ext.util.strip script tag method on client side
View Full Code Here

  /**
   *
   * @param username
   */
  public void addPresenceListener(final String username) {
    PacketListener packetListener = new PacketListener() {
      public void processPacket(Packet packet) {
        try {
          GenericEventListener listener = listeners.get(username);
          if (listener == null) {
            log.warn("could not route presence event as presence listener is null for user: "+username);
View Full Code Here

  public boolean connect() {
    try {
      //XMPPConnection.DEBUG_ENABLED = true;
      connection = new XMPPConnection(host,port,StringUtils.parseServer(jid));
      presences = new HashMap<String,PresenceWrapper>();
      connection.addPacketListener(new PacketListener() {
        public void processPacket(Packet packet) {
          System.out.println("Received packet: " + packet.toXML());
          if(!(packet instanceof Presence)) return;
          //System.out.println(" -- IS Presence packet");
          Presence presence = (Presence)packet;
View Full Code Here

        txtTopic.setText(roomInfo.getSubject());
    } catch (XMPPException e) {
      e.printStackTrace();
    }
   
    mucMessageListener = new PacketListener() {
      public void processPacket(Packet packet) {
        //processMessage((Message) packet);
      }
    };
    muc.addMessageListener(mucMessageListener);
    participantListener = new PacketListener() {
      public void processPacket(Packet packet) {
      }
    };
    muc.addParticipantListener(participantListener);
    participantStatusListener = new ParticipantStatusListener() {
View Full Code Here

                    throw new RuntimeException("Error while receiving file: " + e.getLocalizedMessage(),e);
                  }
                }
              });
            } });
          conn.addPacketListener(new PacketListener(){
            public void processPacket(Packet packet) {
              //System.out.println("Got Packet from " + packet.getFrom() + " : " + packet.getClass().toString() + " :  " + packet.toString());
              if(packet instanceof Message) {
                account.chatWindowExtensionManager.handleMessage((Message)packet);
              } else if(packet instanceof Presence) {
View Full Code Here

    else {
      historyWriter = new HistoryWriter();
      historyWriter.start();
    }
   
    this.conn.addPacketListener(new PacketListener() {
      public void processPacket(Packet packet) {
        writeQueue.add(new PacketWrapper(packet,PacketWrapper.TYPE_RECEIVED));
      } },new AndFilter());
    this.conn.addPacketWriterListener(new PacketListener(){
      public void processPacket(Packet packet) {
        writeQueue.add(new PacketWrapper(packet,PacketWrapper.TYPE_SENT));
      }},new AndFilter());
  }
View Full Code Here

TOP

Related Classes of org.jivesoftware.smack.PacketListener

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.