Examples of XMPPIOService


Examples of tigase.xmpp.XMPPIOService

          JIDUtils.getNodeID(getName(), jid)));
    }
  }

  protected XMPPIOService getXMPPIOServiceInstance() {
    return new XMPPIOService();
  }
View Full Code Here

Examples of tigase.xmpp.XMPPIOService

          JIDUtils.getNodeID(getName(), jid)));
    }
  }

  protected XMPPIOService getXMPPIOServiceInstance() {
    return new XMPPIOService();
  }
View Full Code Here

Examples of tigase.xmpp.XMPPIOService

      writePacketToSocket(packet);
    } // end of else
  }

  protected void processCommand(final Packet packet) {
    XMPPIOService serv = getXMPPIOService(packet);
    switch (packet.getCommand()) {
    case GETFEATURES:
      if (packet.getType() == StanzaType.result) {
        List<Element> features = getFeatures(getXMPPSession(packet));
        Element elem_features = new Element("stream:features");
        elem_features.addChildren(features);
        elem_features.addChildren(Command.getData(packet));
        Packet result = new Packet(elem_features);
        result.setTo(packet.getTo());
        writePacketToSocket(result);
      } // end of if (packet.getType() == StanzaType.get)
      break;
    case STARTTLS:
      if (serv != null) {
        log.finer("Starting TLS for connection: " + serv.getUniqueId());
        try {
          // Note:
          // If you send <proceed> packet to client you must expect
          // instant response from the client with TLS handshaking data
          // before you will call startTLS() on server side.
          // So the initial handshaking data might be lost as they will
          // be processed in another thread reading data from the socket.
          // That's why below code first removes service from reading
          // threads pool and then sends <proceed> packet and starts TLS.
          Element proceed = Command.getData(packet, "proceed", null);
          Packet p_proceed = new Packet(proceed);
           SocketReadThread readThread = SocketReadThread.getInstance();
           readThread.removeSocketService(serv);
          //          writePacketToSocket(serv, p_proceed);
           serv.addPacketToSend(p_proceed);
           serv.processWaitingPackets();
          serv.startTLS(false);
          //          serv.call();
           readThread.addSocketService(serv);
        } catch (IOException e) {
          log.warning("Error starting TLS: " + e);
        } // end of try-catch
      } else {
        log.warning("Can't find sevice for STARTTLS command: " +
          packet.getStringData());
      } // end of else
      break;
    case REDIRECT:
      String command_sessionId = Command.getFieldValue(packet, "session-id");
      String newAddress = packet.getFrom();
      String old_receiver = changeDataReceiver(packet, newAddress,
        command_sessionId, serv);
      if (old_receiver != null) {
        log.fine("Redirecting data for sessionId: " + command_sessionId
          + ", to: " + newAddress);
        Packet response = null;
//         response = packet.commandResult(null);
//         Command.addFieldValue(response, "session-id", command_sessionId);
//         Command.addFieldValue(response, "action", "close");
//         response.getElement().setAttribute("to", old_receiver);
//         addOutPacket(response);
        response = packet.commandResult(null);
        Command.addFieldValue(response, "session-id", command_sessionId);
        Command.addFieldValue(response, "action", "activate");
        response.getElement().setAttribute("to", newAddress);
        addOutPacket(response);
      } else {
        log.finest("Connection for REDIRECT command does not exist, ignoring "
          + "packet: " + packet.toString());
      }
      break;
    case STREAM_CLOSED:

      break;
    case GETDISCO:

      break;
    case CLOSE:
      if (serv != null) {
        serv.stop();
      } else {
        log.fine("Attempt to stop non-existen service for packet: "
          + packet.getStringData()
          + ", Service already stopped?");
      } // end of if (serv != null) else
View Full Code Here

Examples of tigase.xmpp.XMPPIOService

//      hostnames.add(host);
//    } // end of for ()
  }

  private XMPPResourceConnection getXMPPSession(Packet p) {
    XMPPIOService serv = getXMPPIOService(p);
    return serv == null ? null :
      (XMPPResourceConnection)serv.getSessionData().get("xmpp-session");
  }
View Full Code Here

Examples of tigase.xmpp.XMPPIOService

  protected long getMaxInactiveTime() {
    return 24*HOUR;
  }

  protected XMPPIOService getXMPPIOServiceInstance() {
    return new XMPPIOService();
  }
View Full Code Here

Examples of tigase.xmpp.XMPPIOService

      }

      String cid = getConnectionId(packet);
      log.finest("Connection ID is: " + cid);
      synchronized(servicesByHost_Type) {
        XMPPIOService serv = servicesByHost_Type.get(cid);
        if (serv == null || !writePacketToSocket(serv, packet)) {
          addWaitingPacket(cid, packet, waitingPackets);
        } // end of if (serv != null) else
      }
    } // end of else
View Full Code Here

Examples of tigase.xmpp.XMPPIOService

        processDialback(p, serv, results);
        for (Packet res: results) {
          String cid = res.getTo();
          log.finest("Sending dialback result: " + res.getStringData()
            + " to " + cid);
          XMPPIOService sender = handshakingByHost_Type.get(cid);
          if (sender == null) {
            sender = servicesByHost_Type.get(cid);
          }
          log.finest("cid: " + cid
            + ", writing packet to socket: " + res.getStringData());
View Full Code Here

Examples of tigase.xmpp.XMPPIOService

      return;
    }
    String cid = getConnectionId(local_hostname, remote_hostname,
      service.connectionType());
    boolean stopped = false;
    XMPPIOService serv = servicesByHost_Type.get(cid);
    // This checking is necessary due to specific s2s behaviour which
    // I don't fully understand yet, possible bug in my s2s implementation
    if (serv == service) {
      stopped = true;
      servicesByHost_Type.remove(cid);
View Full Code Here

Examples of tigase.xmpp.XMPPIOService

  }

  public void handleDialbackSuccess(final String connect_jid) {
    log.finest("handleDialbackSuccess: connect_jid="+connect_jid);
    Packet p = null;
    XMPPIOService serv = servicesByHost_Type.get(connect_jid);
    ServerPacketQueue waiting = waitingPackets.remove(connect_jid);
    if (waiting != null) {
      while ((p = waiting.poll()) != null) {
        log.finest("Sending packet: " + p.getStringData());
        writePacketToSocket(serv, p);
View Full Code Here

Examples of tigase.xmpp.XMPPIOService

  private void initServiceMapping(String local_hostname, String remote_hostname,
    String cid, XMPPIOService serv) {
    // Assuming this is the first packet from that connection which
    // tells us for what domain this connection is we have to map
    // somehow this IP address to hostname
    XMPPIOService old_serv = (handshakingByHost_Type.get(cid) != null ?
      handshakingByHost_Type.get(cid) : servicesByHost_Type.get(cid));
    if (old_serv != serv) {
      serv.getSessionData().put("local-hostname", local_hostname);
      serv.getSessionData().put("remote-hostname", remote_hostname);
      handshakingByHost_Type.put(cid, serv);
      // Apparently some servers open more than 1 connection and apparently
      // this is correct. So, let's try to not stop the old connection if it
      // it accept type....
      if (old_serv != null
        && old_serv.connectionType() != ConnectionType.accept) {
        log.finest("Stopping old connection for: " + cid);
        old_serv.stop();
      }
    }
  }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.