varspool / Wrench

A simple PHP WebSocket implementation for PHP 7.1
Do What The F*ck You Want To Public License
596 stars 210 forks source link

Add a loop object to allow customizing when the server stops #99

Closed dominics closed 7 years ago

dominics commented 7 years ago

Fixes #77

Adds a LoopInterface, which consists of the single method shouldContinue(): bool. Set the loop on the server with $server->setLoop(LoopInterface $loop) at any point before you call $server->run().

Includes a test example which is a loop interface configured to only loop five times: https://github.com/dominics/Wrench/blob/1851fc039338edece476e8606085e260627fa8af/test/ServerTest.php#L48L59