sender = $sender; $this->log = $log; } /** * Submit to a web-socket server. */ public function submit(string $topic, ?string $userId = null, ?stdClass $data = null): void { if (!$data) { $data = (object) []; } if ($userId) { $data->userId = $userId; } $data->topicId = $topic; $message = Json::encode($data); try { $this->sender->send($message); } catch (Throwable $e) { $this->log->error("WebSocketSubmission: " . $e->getMessage()); } } }