Ejemplo n.º 1
0
  public static Struct call(PageContext pc, String Hash, String Algorithm) throws PageException {
    Cast Caster = CFMLEngineFactory.getInstance().getCastUtil();

    try {
      return Caster.toStruct(Impl.info(Hash, Algorithm));
    } catch (Exception Ex) {
      throw Caster.toPageException(Ex);
    }
  }
Ejemplo n.º 2
0
  @Override
  public void init(GatewayEngine engine, String id, String cfcPath, Map config)
      throws GatewayException {
    this.engine = engine;
    cfmlEngine = CFMLEngineFactory.getInstance();
    caster = cfmlEngine.getCastUtil();
    creator = cfmlEngine.getCreationUtil();
    this.cfcPath = cfcPath;
    this.id = id;

    // config
    Object oPort = config.get("port");
    port = caster.toIntValue(oPort, 1225);

    Object oWM = config.get("welcomeMessage");
    String strWM = caster.toString(oWM, "").trim();
    if (strWM.length() > 0) welcomeMessage = strWM;
  }
Ejemplo n.º 3
0
  @Override
  public String sendMessage(Map _data) {
    Struct data = caster.toStruct(_data, null, false);
    String msg = (String) data.get("message", null);
    String originatorID = (String) data.get("originatorID", null);

    String status = "OK";
    if (msg != null) {

      Iterator<SocketServerThread> it = sockets.iterator();
      SocketServerThread sst;
      try {
        boolean hasSend = false;
        while (it.hasNext()) {
          sst = it.next();
          if (originatorID != null && !sst._id.equalsIgnoreCase(originatorID)) continue;
          sst.writeOutput(msg);
          hasSend = true;
        }

        if (!hasSend) {
          if (sockets.size() == 0) {
            error("There is no connection");
            status = "EXCEPTION";
          } else {
            it = sockets.iterator();
            StringBuilder sb = new StringBuilder();
            while (it.hasNext()) {
              if (sb.length() > 0) sb.append(", ");
              sb.append(it.next()._id);
            }
            error(
                "There is no connection with originatorID ["
                    + originatorID
                    + "], available originatorIDs are ["
                    + sb
                    + "]");
            status = "EXCEPTION";
          }
        }
      } catch (Exception e) {
        e.printStackTrace();
        error("Failed to send message with exception: " + e.toString());
        status = "EXCEPTION";
      }
    }
    return status;
  }