@Override
  public void disconnected(boolean onError) {
    final XMPPConnection connection = myFacade.getConnection();

    LOG.info("Jabber disconnected: " + connection.getUser());
    connection.removePacketListener(mySubscribeListener);
    mySubscribeListener = null;
    connection.removePacketListener(myMessageListener);
    myMessageListener = null;

    final Roster roster = connection.getRoster();
    if (roster != null) {
      roster.removeRosterListener(myRosterListener);
    }
    myRosterListener = null;

    myIDEtalkUsers.clear();
    myUser2Presence.clear();
    myUser2Thread.clear();

    if (onError && reconnectEnabledAndNotStarted()) {
      LOG.warn(getMsg("jabber.server.was.disconnected", myReconnectTimeout / 1000));
      myReconnectProcess = myIdeFacade.runOnPooledThread(new MyReconnectRunnable());
    }
  }
 @Override
 public void connected(XMPPConnection connection) {
   LOG.info("Jabber connected");
   if (mySubscribeListener == null) {
     mySubscribeListener = new MySubscribeListener();
     connection.addPacketListener(mySubscribeListener, new PacketTypeFilter(Presence.class));
   }
   if (myMessageListener == null) {
     myMessageListener = new MyMessageListener();
     connection.addPacketListener(myMessageListener, new PacketTypeFilter(Message.class));
   }
 }