Package tigase.server

Examples of tigase.server.Packet


          res_vals.put(VALID, "" + valid);
          result = clel.createMethodResponse(getComponentId(),
            "result", res_vals);
        }
        addOutPacket(new Packet(result.getClusterElement()));
      }
      break;
    case get:

      break;
    case result:
      if (ClusterMethods.CHECK_DB_KEY.toString().equals(clel.getMethodName())) {
        String cid = clel.getMethodParam(CID);
        String key = clel.getMethodParam(KEY);
        String forkey_sessionId = clel.getMethodParam(FORKEY_SESSION_ID);
        String asking_sessionId = clel.getMethodParam(ASKING_SESSION_ID);
        boolean valid = "true".equals(clel.getMethodResultVal(VALID));
        String from = JIDUtils.getNodeNick(cid);
        String to = JIDUtils.getNodeHost(cid);
        sendVerifyResult(from, to, forkey_sessionId, valid,
          getServerConnections(cid), asking_sessionId);
      }
      break;
    case error:
      // There might be many different errors...
      // But they all mean the cluster node is unreachable.
      // Let's leave custom handling each error type for later...
      String from = packet.getElemFrom();
      clel.addVisitedNode(from);
      addOutPacket(new Packet(ClusterElement.createForNextNode(clel,
            cluster_nodes, getComponentId()).getClusterElement()));
      break;
    default:
      break;
    }
View Full Code Here


        params.put(ASKING_SESSION_ID, asking_sessionId);
        Element check_db_key =
          ClusterElement.createClusterMethodCall(getComponentId(), cluster_node,
            StanzaType.set, ClusterMethods.CHECK_DB_KEY.toString(),
            params).getClusterElement();
        addOutPacket(new Packet(check_db_key));
      }
      return null;
    }
  }
View Full Code Here

//     }
    super.writePacketToSocket(p);
  }

  public Queue<Packet> processSocketData(XMPPIOService serv) {
    Packet p = null;
    while ((p = serv.getReceivedPackets().poll()) != null) {
      if (log.isLoggable(Level.FINEST)) {
        log.finest("Processing socket data: " + p.getStringData());
      }
      if (p.getElemName().equals("handshake")) {
        processHandshake(p, serv);
      } else {
        if (p.isRouted()) {
//           processReceivedRid(p, serv);
//           processReceivedAck(p, serv);
          p = p.unpackRouted();
        } // end of if (p.isRouted())
        addOutPacket(p);
      }
    } // end of while ()
    return null;
View Full Code Here

            + major_ver + "." + minor_ver + "." + bugfix_ver + "' version of Tigase"
            + " server. A new version of the server has been released: '"
            + major + "." + minor + "." + bugfix + "' and it is available for"
            + " download at address: " + link + "\n\n" + intro_msg);
          message.addChild(body);
          receiver.addPacket(new Packet(message));
        }
      } catch (IOException e) {
        log.log(Level.WARNING, "Can not check updates for URL: " + VERSION_URL, e);
      } catch (InterruptedException e) {
        stopped = true;
View Full Code Here

      try {
        String loc_digest = Algorithms.hexDigest(id, secret, "SHA");
        log.finest("Calculating digest: id="+id+", secret="+secret
          +", digest="+loc_digest);
        if (digest != null && digest.equals(loc_digest)) {
          Packet resp = new Packet(new Element("handshake"));
          writePacketToSocket(serv, resp);
          serviceConnected(serv);
        } else {
          log.warning("Handshaking password doesn't match, disconnecting...");
          serv.stop();
View Full Code Here

      (String)serv.getSessionData().get(PORT_REMOTE_HOST_PROP_KEY);
    log.info("Connected to: " + addr);
    updateServiceDiscovery(addr, XMLNS + " connected");
    Map<String, String> method_params = new LinkedHashMap<String, String>();
    method_params.put("connected", addr);
    addOutPacket(new Packet(ClusterElement.createClusterMethodCall(
          getComponentId(), cluster_controller_id,
          StanzaType.set, ClusterMethods.UPDATE_NODES.toString(),
          method_params).getClusterElement()));
//     synchronized (waiting_packs) {
//       LinkedHashMap<Long, Packet> waiting_packets =
View Full Code Here

    String addr = (String)sessionData.get(PORT_REMOTE_HOST_PROP_KEY);
    log.info("Disonnected from: " + addr);
    updateServiceDiscovery(addr, XMLNS + " disconnected");
    Map<String, String> method_params = new LinkedHashMap<String, String>();
    method_params.put("disconnected", addr);
    addOutPacket(new Packet(ClusterElement.createClusterMethodCall(
          getComponentId(), cluster_controller_id,
          StanzaType.set, ClusterMethods.UPDATE_NODES.toString(),
          method_params).getClusterElement()));
    ++totalNodeDisconnects;
    int hour = TimeUtils.getHourNow();
View Full Code Here

        admin = false;
        msg = "You are not admin. You can safely play with the settings as"
          + " you can not change anything.";
        if (packet.getStrCommand() != null
          && packet.getStrCommand().endsWith(DEF_SM_NAME)) {
          Packet result = packet.commandResult("result");
          Command.addFieldValue(result, "Note",  msg, "fixed");
          Command.addFieldValue(result, "Note",
            "Restricted area, only admin can see these settings.", "fixed");
          results.offer(result);
          return;
        }
      } else {
        try {
          results.offer(Authorization.NOT_AUTHORIZED.getResponseMessage(packet,
              "You are not authorized for this action.", true));
        } catch (PacketErrorTypeException e) {
          log.warning("Packet processing exception: " + e);
        }
        return;
      }
    }

    log.finest("Command received: " + packet.getStringData());

    Command.Action action = Command.getAction(packet);
    if (action == Command.Action.cancel) {
      Packet result = packet.commandResult(null);
      results.offer(result);
      return;
    }

    switch (packet.getCommand()) {
    case OTHER:
      if (packet.getStrCommand() != null) {
        if (packet.getStrCommand().startsWith("config/list/")) {
          String[] spl = packet.getStrCommand().split("/");
          Packet result = packet.commandResult("result");
          Command.addFieldValue(result, "Note",  msg, "fixed");
          Map<String, Object> allprop = getAllProperties(spl[2]);
          for (Map.Entry<String, Object> entry: allprop.entrySet()) {
            Command.addFieldValue(result, XMLUtils.escape(entry.getKey()),
              XMLUtils.escape(objectToString(entry.getValue())));
          } // end of for (Map.Entry entry: prop.entrySet())
          results.offer(result);
        }
        if (packet.getStrCommand().startsWith("config/set/")) {
          String[] spl = packet.getStrCommand().split("/");
          Packet result = packet.commandResult("result");
          Command.addFieldValue(result, "Note",  msg, "fixed");
          if (Command.getData(packet) == null) {
            prepareConfigData(result, spl[2]);
            results.offer(result);
          } else {
View Full Code Here

  /**
   * Describe <code>processWaitingPackets</code> method here.
   *
   */
  public void processWaitingPackets() throws IOException {
    Packet packet = null;
    while ((packet = waitingPackets.poll()) != null) {
      if (log.isLoggable(Level.FINEST)) {
        log.finest("Sending packet: " + packet.toString());
      }
      writeRawData(packet.getStringData());
      if (log.isLoggable(Level.FINEST)) {
        log.finest("SENT: " + packet.getStringData());
      }
    } // end of while (packet = waitingPackets.poll() != null)
  }
View Full Code Here

              //log.finer("Read element: " + elem.getName());
              if (log.isLoggable(Level.FINEST)) {
                log.finest("Read packet: " + elem.toString());
              }
              //              System.out.print(elem.toString());
              addReceivedPacket(new Packet(elem));
            } // end of while ((elem = elems.poll()) != null)
          catch (Exception ex) {
            log.log(Level.INFO, "Incorrect XML data: " + new String(data)
              + ", stopping connection: " + getUniqueId()
              + ", exception: ", ex);
View Full Code Here

TOP

Related Classes of tigase.server.Packet

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.