Skip to content

Commit

Permalink
pub to pubsub url as well
Browse files Browse the repository at this point in the history
  • Loading branch information
ylebre committed Nov 9, 2020
1 parent 0a699e6 commit f3862bb
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions src/Server.php
Original file line number Diff line number Diff line change
Expand Up @@ -303,11 +303,15 @@ private function handleCreateDirectoryRequest(Response $response, string $path)
}

private function sendWebsocketUpdate($path) {
$client = new \WebSocket\Client("ws://localhost:8080/");
$client->send("pub https://localhost$path\n");
$baseUrl = "https://" . $request->getServerParams()["SERVER_NAME"];
$pubsub = getenv('PUBSUB_URL') ?: ("http://" . $request->getServerParams()["SERVER_NAME"] . ":8080/");
$pubsub = str_replace("https://", "ws://", $pubsub);
$pubsub = str_replace("http://", "ws://", $pubsub);
$client = new \WebSocket\Client($pubsub);
$client->send("pub $baseUrl$path\n");
while ($path != "/") {
$path = $this->parentPath($path);
$client->send("pub https://localhost$path\n");
$client->send("pub $baseUrl$path\n");
}
}

Expand Down

0 comments on commit f3862bb

Please sign in to comment.