Example #1
0
        public void SND1()
        {
            string s = ReadC();
              int id = ReadI();

              SendSTART();
            if (s == "START") {
              Server parent = (Server) LinkGetParent();
              if (parent != null && parent.cl[id].LinkIsConnected()) {
            cl[id].LinkCreateChild(parent.cl[id]);
              } else {
            cl[id].LinkCreate(ConfigGetDebug());
              }
            } else if (s == "START2") {
              // object already created ERROR
              cl[id].LinkCreate(ConfigGetDebug());
              cl[id].LinkCreate(ConfigGetDebug());
            } else if (s == "START3") {
              Client parent = new Client();
              // parent not connected ERROR
              cl[id].LinkCreateChild(parent);
            } else if (s == "START4") {
              // master not connected ERROR
              cl[id].SlaveWorker(0);
            } else if (s == "START5") {
              // the 'master' have to be a 'parent' without 'child' objects
              // 'slave' identifer out of range (0 <= 10000000 <= 1023)
              SlaveWorker(id, "--name", "wk-cl-" + id, "--srvname", "wk-sv-" + id);
            } else if (s == "STOP") {
              cl[id].LinkDelete();
            } else if (s == "SEND") {
              cl[id].SendSTART();
              String TOK = ReadC();
              ReadProxy(cl[id]);
              cl[id].SendEND(TOK);
            } else if (s == "WAIT") {
              cl[id].SendSTART();
              ReadProxy(cl[id]);
              cl[id].SendEND_AND_WAIT("ECOI", 5);
              SendI(cl[id].ReadI()+1);
            } else if (s == "CALLBACK") {
              cl[id].SendSTART();
              ReadProxy(cl[id]);
              cl[id].i = -1;
              cl[id].SendEND_AND_CALLBACK("ECOI", cl[id].ECOI_CB);
              cl[id].ProcessEvent(10, MqS.WAIT.ONCE);
              SendI(cl[id].i+1);
            } else if (s == "ERR-1") {
              cl[id].SendSTART();
              try {
            ReadProxy(cl[id]);
            cl[id].SendEND_AND_WAIT("ECOI", 5);
              } catch (Exception ex) {
            ErrorSet(ex);
            SendI(ErrorGetNum());
            SendC(ErrorGetText());
            ErrorReset();
              }
            }
              SendRETURN();
        }
Example #2
0
        public void SND2()
        {
            string s = ReadC();
              int id = ReadI();
              MqS cl = SlaveGet(id);

              SendSTART();
            if (s == "CREATE") {
              List<string> LIST = new List<string>();
              while (ReadItemExists())
            LIST.Add(ReadC());
              LIST.Add("--name");
              LIST.Add("wk-cl-" + id);
              LIST.Add("@");
              LIST.Add("--name");
              LIST.Add("wk-sv-" + id);
              SlaveWorker(id, LIST.ToArray());
            } else if (s == "CREATE2") {
              Client c = new Client();
              c.LinkCreate(ConfigGetDebug());
              SlaveCreate (id, c);
            } else if (s == "DELETE") {
              SlaveDelete(id);
              SendC(SlaveGet(id) == null ? "OK" : "ERROR");
            } else if (s == "SEND") {
              cl.SendSTART();
              String TOK = ReadC();
              ReadProxy(cl);
              cl.SendEND(TOK);
            } else if (s == "WAIT") {
              cl.SendSTART();
              cl.SendN(ReadN());
              cl.SendEND_AND_WAIT("ECOI", 5);
              SendI(cl.ReadI()+1);
            } else if (s == "CALLBACK") {
              cl.SendSTART();
              ReadProxy(cl);
              i = -1;
              cl.SendEND_AND_CALLBACK("ECOI", ((Server)cl).SetMyInt);
              cl.ProcessEvent(10, MqS.WAIT.ONCE);
              SendI(i+1);
            } else if (s == "MqSendEND_AND_WAIT") {
              string TOK = ReadC();
              cl.SendSTART();
              while (ReadItemExists())
            ReadProxy(cl);
              cl.SendEND_AND_WAIT(TOK, 5);
              while (cl.ReadItemExists())
            cl.ReadProxy(this);
            } else if (s == "MqSendEND") {
              string TOK = ReadC();
              cl.SendSTART();
              while (ReadItemExists())
            ReadProxy(cl);
              cl.SendEND(TOK);
              return;
            } else if (s == "ERR-1") {
              ClientERR2 c = new ClientERR2();
              c.LinkCreate(ConfigGetDebug());
            } else if (s == "isSlave") {
              SendO(cl.SlaveIs());
            }
              SendRETURN();
        }
Example #3
0
 void IServerSetup.ServerSetup()
 {
     if (SlaveIs()) {
     // add "slave" services here
       } else {
     for (int i=0;i<3;i++) {
       cl[i] = new Client();
       cl[i].ConfigSetName("cl-" + i);
       cl[i].ConfigSetSrvName("sv-" + i);
     }
     // add "master" services here
     ServiceCreate("ECOI", ECOI);
     ServiceCreate("ECOU", ECOU);
     ServiceCreate("SETU", SETU);
     ServiceCreate("GETU", GETU);
     ServiceCreate("ECOW", new ECOW());
     ServiceCreate("ECOS", ECOS);
     ServiceCreate("ECOD", ECOD);
     ServiceCreate("ECOF", ECOF);
     ServiceCreate("ECOC", ECOC);
     ServiceCreate("ECOL", ECOL);
     ServiceCreate("ECLI", ECLI);
     ServiceCreate("LST1", LST1);
     ServiceCreate("LST2", LST2);
     ServiceCreate("ECUL", ECUL);
     ServiceCreate("ECOO", ECOO);
     ServiceCreate("ECOY", ECOY);
     ServiceCreate("ECOB", ECOB);
     ServiceCreate("BUF1", BUF1);
     ServiceCreate("BUF2", BUF2);
     ServiceCreate("BUF3", BUF3);
     ServiceCreate("ERR2", ERR2);
     ServiceCreate("ERR3", ERR3);
     ServiceCreate("ERR4", ERR4);
     ServiceCreate("ERRT", ERRT);
     ServiceCreate("CSV1", CSV1);
     ServiceCreate("SLEP", SLEP);
     ServiceCreate("USLP", USLP);
     ServiceCreate("ECON", ECON);
     ServiceCreate("MSQT", MSQT);
     ServiceCreate("SND1", SND1);
     ServiceCreate("SND2", SND2);
     ServiceCreate("REDI", REDI);
     ServiceCreate("RDUL", RDUL);
     ServiceCreate("GTCX", GTCX);
     ServiceCreate("GTTO", GTTO);
     ServiceCreate("LANG", LANG);
     ServiceCreate("INIT", INIT);
     ServiceCreate("CNFG", CNFG);
     ServiceCreate("ERLR", ERLR);
     ServiceCreate("ERLS", ERLS);
     ServiceCreate("CFG1", CFG1);
     ServiceCreate("PRNT", PRNT);
     ServiceCreate("TRNS", TRNS);
     ServiceCreate("TRN2", TRN2);
       }
 }