Askedio / laravel-ratchet

A Ratchet Server built for Laravel
https://medium.com/asked-io/creating-a-ratchet-web-socket-server-with-laravel-743e3dae766f
MIT License
186 stars 47 forks source link

Access the loop from class #30

Open elpoleto opened 5 years ago

elpoleto commented 5 years ago

Is there no way to access the main loop throught the application class? It would be useful to add timer etc

In ratchet is possible as (for example WebSocket Server): $server = new IoServer(new HttpServer(new WsServer(new Chat($loop))), $socket, $loop);

simonhamp commented 5 years ago

@elpoleto I've not needed to do this before and haven't read up on this feature, so I'm not 100% clear on why you would do this. Could you provide a solid use-case?

elpoleto commented 5 years ago

yes, sure, in my case i communicate with a iot device. for some actions i need the $loop->addTimer() to check a sort of timeouts but in my own class (in my case extends "RatchetWsServer") there is no access to the loop

elpoleto commented 5 years ago

For now i implemented my own command and exclude the package one by composer.json as: .... "autoload": { "files": [ "app/Library/helpers.php", "app/overrides/RatchetServerCommand.php" ], "classmap": [ "database/seeds", "database/factories" ], "psr-4": { "App\": "app/" }, "exclude-from-classmap": [ "vendor/askedio/laravel-ratchet/src/Console/Commands/RatchetServerCommand.php" ] }, .....

all this to rewrite this simple call in method "createServerInstance()", that is private, to pass the $loop to the class .... $this->serverInstance = $this->ratchetServer = new $class($this, $this->getEventLoop()) ....

elpoleto commented 4 years ago

Is this project still alive?

gcphost commented 4 years ago

Hi

We are looking for more maintainers and am happy to merge PRs but there is not much active development on this project.