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);