Skip to content

Commit 1a1066b

Browse files
committed
Standalone functionality
Calling start(true) will immediately start the event loop
1 parent d86a989 commit 1a1066b

File tree

3 files changed

+4
-2
lines changed

3 files changed

+4
-2
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,3 +23,4 @@ Thumbs.db
2323
composer.lock
2424
*.cache
2525
/json
26+
verify.json

run.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,6 @@
1717
$envConfig['HOST_ADDR'] . ':' . $envConfig['HOST_PORT']
1818
);
1919

20-
$server->init(null, true);
20+
$server->init(null, true); // Standalone without an event loop or ReactPHP server
2121
$server->setLogger(true);
2222
$server->start();

src/Server.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,14 +72,15 @@ public function init(?LoopInterface $loop = null, bool $stream_socket_server = f
7272
*
7373
* This method sets up an event-driven server to handle incoming client connections.
7474
*/
75-
public function start(): void
75+
public function start(bool $start_loop = false): void
7676
{
7777
if (! $this->initialized) {
7878
$this->init();
7979
}
8080
if (! $this->running) {
8181
if ($this->server instanceof HttpServer) {
8282
$this->server->listen($this->socket);
83+
if ($start_loop) $this->loop->run();
8384
} elseif (is_resource($this->server)) {
8485
$this->running = true;
8586
while ($this->running) {

0 commit comments

Comments
 (0)