@Override
  public void notify(Packet packet) {
    Session s = packet.getSession();

    try {
      Session stored_session = index.getSession(s.getID());
      stored_session.getWindow().update("Partner disconnected...");
      stored_session.closeStream();
    } catch (Exception e) {
      e.printStackTrace();
    }
  }
  public void notify(Packet packet) {
    try {
      Session session = packet.getSession();
      session.setUser(new User(packet.getFrom()));
      session.setID(packet.getID());

      Preferences p = new AppPrefs().getPrefs();

      // If there's no auth attribute, default to authenticated,
      // if there is, use the value sent
      // Always defaults to authenticated.
      boolean auth =
          packet.getAttribute("authenticated").isEmpty()
              ? true
              : (packet.getAttribute("authenticated").equalsIgnoreCase("true")) ? true : false;

      // If no auth is requested,
      // check preferences to see if we allow that
      if (!auth && !p.getBoolean("allow_unauthenticated_conversations", false)) return;

      if (index.getSession(packet.getID()) == null) {
        if (session.getStatus() == Session.CONNECTED) {
          System.out.println(session.getSocket().getInetAddress().getHostAddress());
          Session s =
              Server.createClient(
                  session.getSocket().getInetAddress().getHostAddress(),
                  packet.getAttribute("return-port"),
                  session.getLocalPort(),
                  session.getUser(),
                  session.getID());
          s.setAuthenticated(auth);
          s.setCipherType(CipherAlgorithm.AES);
          s.setCipherKey(new Key(KeySize.K256).getKey());
          index.addSession(s);
        }
      }

      session.setStatus(Session.STREAMING);
    } catch (Exception ex) {
      ex.printStackTrace();
    }
  }