Example #1
0
 public function SND2()
 {
     $s = $this->ReadC();
     $id = $this->ReadI();
     $cl = $this->SlaveGet($id);
     $this->SendSTART();
     switch ($s) {
         case "CREATE":
             $args = array();
             while ($this->ReadItemExists()) {
                 $args[] = ReadC();
             }
             array_push(&$args, "--name", "wk-cl-" . $id, "@", "--name", "wk-sv-" . $id);
             $this->SlaveWorker($id, $args);
             break;
         case "CREATE2":
             $slv = new Client();
             $slv->LinkCreate($this->ConfigGetDebug());
             $this->SlaveCreate($id, $slv);
             break;
         case "DELETE":
             $this->SlaveDelete($id);
             $this->SlaveGet($id) == NULL ? $this->SendC("OK") : $this->SendC("ERROR");
             break;
         case "SEND":
             $cl->SendSTART();
             $tok = $this->ReadC();
             $cl->SendU($this->ReadU());
             $cl->SendEND($tok);
             break;
         case "WAIT":
             $cl->SendSTART();
             $cl->SendN($this->ReadN());
             $cl->SendEND_AND_WAIT("ECOI", 5);
             $this->SendI($cl->ReadI() + 1);
             break;
         case "CALLBACK":
             $cl->SendSTART();
             $cl->SendU($this->ReadU());
             $this->i = -1;
             $cl->SendEND_AND_CALLBACK("ECOI", array(&$this, "Callback2"));
             $cl->ProcessEvent(10, MqS::WAIT_ONCE);
             $this->SendI($this->i + 1);
             break;
         case "MqSendEND_AND_WAIT":
             $tok = $this->ReadC();
             $cl->SendSTART();
             while ($this->ReadItemExists()) {
                 $cl->SendU($this->ReadU());
             }
             $cl->SendEND_AND_WAIT($tok, 5);
             while ($cl->ReadItemExists()) {
                 $this->SendU($cl->ReadU());
             }
             break;
         case "MqSendEND":
             $tok = $this->ReadC();
             $cl->SendSTART();
             while ($this->ReadItemExists()) {
                 $cl->SendU($this->ReadU());
             }
             $cl->SendEND($tok);
             return;
         case "ERR-1":
             $slv = new ClientERR2();
             $slv->LinkCreate($this->ConfigGetDebug());
             break;
         case "isSlave":
             $this->SendO($cl->SlaveIs());
             break;
     }
     $this->SendRETURN();
 }