diff --git a/HauptManager/module.php b/HauptManager/module.php index f6f4491..5e0284d 100644 --- a/HauptManager/module.php +++ b/HauptManager/module.php @@ -53,7 +53,34 @@ class HauptManager extends IPSModule private function StartWebSocketServer() { $server = new \Ratchet\App('localhost', 8080); - $server->route('/ws', new WebSocketHandler($this), ['*']); + $server->route('/ws', new class($this) implements \Ratchet\MessageComponentInterface { + private $module; + + public function __construct($module) + { + $this->module = $module; + } + + public function onOpen(\Ratchet\ConnectionInterface $conn) + { + $this->module->AddClient($conn); + } + + public function onClose(\Ratchet\ConnectionInterface $conn) + { + $this->module->RemoveClient($conn); + } + + public function onError(\Ratchet\ConnectionInterface $conn, \Exception $e) + { + $conn->close(); + } + + public function onMessage(\Ratchet\ConnectionInterface $from, $msg) + { + // Nachrichtenverarbeitung implementieren + } + }, ['*']); $server->run(); } @@ -82,34 +109,4 @@ class HauptManager extends IPSModule $this->UpdateFormField('ClientList', 'values', json_encode($clientList)); } } - -class WebSocketHandler implements \Ratchet\MessageComponentInterface -{ - private $module; - - public function __construct($module) - { - $this->module = $module; - } - - public function onOpen(\Ratchet\ConnectionInterface $conn) - { - $this->module->AddClient($conn); - } - - public function onClose(\Ratchet\ConnectionInterface $conn) - { - $this->module->RemoveClient($conn); - } - - public function onError(\Ratchet\ConnectionInterface $conn, \Exception $e) - { - $conn->close(); - } - - public function onMessage(\Ratchet\ConnectionInterface $from, $msg) - { - // Nachrichtenverarbeitung implementieren - } -} ?> \ No newline at end of file diff --git a/library.json b/library.json index 17466a1..fe54c66 100644 --- a/library.json +++ b/library.json @@ -6,7 +6,7 @@ "compatibility": { "version": "7.1" }, - "version": "1.100", + "version": "1.101", "build": 0, "date": 0 } \ No newline at end of file