private function register($loop, $me) { $buffer = ''; // Launching the linker $this->process = new \React\ChildProcess\Process('exec php linker.php', null, array('sid' => $this->sid, 'baseuri' => $this->baseuri)); $this->process->start($loop); // Buffering the incoming data and fire it once its complete $this->process->stdout->on('data', function ($output) use($me, &$buffer) { if (substr($output, -1) == "") { $out = $buffer . substr($output, 0, -1); $buffer = ''; $me->messageOut($out); } else { $buffer .= $output; } }); // The linker died, we close properly the session $this->process->on('exit', function ($output) use($me) { echo colorize($this->sid, 'yellow') . " : " . colorize("linker killed \n", 'red'); $me->process = null; $me->closeAll(); $sd = new \Modl\SessionxDAO(); $sd->delete($this->sid); }); // Debug only, if the linker output some errors $this->process->stderr->on('data', function ($output) use($me) { echo $output; }); }
public function destroy() { $sd = new \Modl\SessionxDAO(); $sd->delete(self::$_sessionid); }
private function closeEmptySession($sid) { // No WebSockets and no linker ? We close the whole session if ($this->sessions[$sid]->countClients() == 0 && $this->sessions[$sid]->process == null) { $sd = new \Modl\SessionxDAO(); $sd->delete($sid); unset($this->sessions[$sid]); } }