Examples of ByteMsg


Examples of ru.vassaev.core.io.ByteMsg

          String n = (grp == null) ? k : grp + "/" + k;
          // ta.setTaskParamString(id_task, n, aprms.getField(k));
          ta.setParamObject(id_task, n, aprms.getField(k));
        }
      } else if (addprms instanceof ByteMsg) {
        ByteMsg msg = (ByteMsg) addprms;
        PrmInterface aprms = msg.getPrmInterface();
        for (String k : aprms.getFieldNames()) {
          String n = (grp == null) ? k : grp + "/" + k;
          // ta.setTaskParamString(id_task, n, aprms.getField(k));
          ta.setParamObject(id_task, n, aprms.getField(k));
        }
View Full Code Here

Examples of ru.vassaev.core.io.ByteMsg

    boolean need_catch = true;
    boolean need_send = true;
    Object v = null;
    ru.vassaev.core.thread.Process prcr = null;
    TimeoutInputStream tis = null;
    ByteMsg msg = null;
    try {
      ru.vassaev.core.thread.Process prc = Process.currentProcess();
      // Переменные потока
      prc.regResourceName(catch_wait, "catch_wait");
      prc.regResourceName(send_wait, "send_wait");
      need_catch = cntx.getPrmNvl("need_catch", true);
      if (!need_catch) {
        need_send = cntx.getPrmNvl("need_send", true);
        if (!need_send)
          return State.DONE_OK;
      }
      msg = poolmsg.occupyOrNew();
      //C02 Установить соединение с хостом
      s = new Socket(host, port);
      connect = 1;
      // Переменные потока
      prc.regResourceName(connect, "connect");
      while (need_catch || need_send) {
        //{C03}
        need_catch = cntx.getPrmNvl("need_catch", true);
        if (need_catch) {
          //{C05}
          catch_wait++;
          prc.regResourceName(catch_wait, "catch_wait");
          InputStream is = s.getInputStream();
          //TPTPMsg msg = new TPTPMsg();
          msg.reset();
/*
          try{
            prcr = prcs.occupyOrNew();
            tis = new TimeoutInputStream(prcr);
            tis.setTimeout(getTimeout(cntx));
            tis.startReadSource(is);
//*/
            msg = msg.receiveMsg(is, msg);
/*          } finally {
            prcs.free(prcr);
          }
//*/
          //{C06}
          Record r = new Record();
          PrmInterface prm = msg.getPrmInterface();
          for (String n : prm.getFieldNames()) {
            v = prm.getField(n);
            n = "msg." + n;
            cntx.log(false, n, "=", v);
            r.setObject(n, v);
            prc.regResourceName(v, n);
          }
          prc.regResourceName(r, "msg.*");
          catch_done++;
          prc.regResourceName(catch_done, "catch_done");
          //{C12}
          cntx.getPrmByFullName("update");// Расчитать
        }
        //{C07}
        need_send = cntx.getPrmNvl("need_send", true);
        if (need_send) {
          send_wait++;
          prc.regResourceName(send_wait, "send_wait");
          //*
          //{C08}
          String msg_grp_in = cntx.getPrmNvl("msg_grp_in", "in");
          Map<String, Object> prms = cntx.getGroupParams(msg_grp_in);
          msg.reset();
          //TPTPMsg msg = new TPTPMsg();
          try {
            PrmInterface prmi = msg.getPrmInterface();
            for (Map.Entry<String, Object> prm : prms.entrySet()) {
              String key = prm.getKey();
              String[] fn = cntx.getFullName(key);
              prmi.setField(fn[1], Strings.getString(cntx.getPrmString(key)));
            }
            //{C10}
            msg.sendTo(s.getOutputStream());

            //msg.sendTo(System.out);
            //System.out.println("\n");
          } finally {
            //poolmsg.free(msg);
View Full Code Here

Examples of ru.vassaev.core.io.ByteMsg

      }
    }

    public ByteMsg callBack(Object[] objs) {
      if (!Null.equ(objs) && objs.length > 1) {
        ByteMsg msg = (ByteMsg)objs[1];
        if (ByteMsg.ACTION.FREE.equals(objs[0])) {
          freeMsg(msg);
          System.out.println("Dropped link " + nameLink);
          try {
            os.close();
View Full Code Here

Examples of ru.vassaev.core.io.ByteMsg

    if (st != null)
      return st;
    Socket s = null;
    try {
      Map<String, Object> prms = cntx.getGroupParams(msg_grp_in);
      ByteMsg msg = poolmsg.occupyOrNew();
      try {
        PrmInterface prmi = msg.getPrmInterface();
        for(Map.Entry<String, Object> prm : prms.entrySet()) {
          String key = prm.getKey();
          String[] fn = cntx.getFullName(key);
          prmi.setField(fn[1], Strings.getString(cntx.getPrmString(key)));
        }
        s = new Socket(host, port);
        msg.sendTo(s.getOutputStream());
      } finally {
        poolmsg.free(msg);
      }
      msg = poolmsg.getFactory().create();
      poolmsg.getFactory().initialization(msg);
      ReadMsg rm = new ReadMsg(msg);
      ByteMsg result;
      Process prc = null;
      try {
        synchronized(sync) {
          prc = prcs.occupyWait();
          prc.setTarget(rm);
          prc.setName("READ_MSG_" + cntx.id_task);
          prc.start(s.getInputStream());
          sync.wait(timeout);
          result = rm.getResultMsg();
          if (result == null) {
            prc.kill();
            throw new TaskException(State.DONE_TOUT, "Timeout of receiving message");
          }
        }
      } finally {
        prcs.free(prc);
      }
      PrmInterface prmi = result.getPrmInterface();
      StringList flds = prmi.getFieldNames();
      for (String fld : flds) {
        cntx.setPrmByFullName(msg_grp_out + "/" + fld, prmi.getField(fld), false);
      }
    } catch (UnknownHostException e) {
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.