Ejemplo n.º 1
0
  @Override
  public void processPacket(Packet packet) {
    Session session;

    Message message = (Message) packet;

    if (message.getType() == Message.Type.chat) {
      String sessionId = message.getFrom();
      String text = message.getBody();

      if (!sessionManager.hasSession(sessionId)) {
        session = sessionManager.createSession(sessionId, this);
        session.setProperty("xmppDebugDestination", sessionId);
        session.setProperty("xmppDestination", sessionId);
      } else {
        session = sessionManager.getSession(sessionId);
      }

      if (text.startsWith("d:")) {
        System.out.println(
            "Setting debug for sessionID (" + sessionId + ") to " + text.substring(2));
        session.setProperty("xmppDebugDestination", text.substring(2));
      }
      if (text.startsWith("D:")) {
        session.setProperty("xmppDebugDestination", "*****@*****.**");
        System.out.println(
            "Setting debug for sessionID (" + sessionId + ") to [email protected]");
      } else {
        session.pushInput(text);
      }
    }
  }
Ejemplo n.º 2
0
 public void debug(Session session, int level, String text) {
   send(session.getProperty("xmppDebugDestination"), "Debug(" + level + "):" + text);
 }
Ejemplo n.º 3
0
 public void send(Session session, String text) {
   send(session.getProperty("xmppDestination"), text);
 }