Skip to content

Commit

Permalink
Add a note about how to get access to the WebSocket client
Browse files Browse the repository at this point in the history
  • Loading branch information
HavokInspiration authored Aug 9, 2017
1 parent 399453d commit 32a377e
Showing 1 changed file with 30 additions and 0 deletions.
30 changes: 30 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,11 @@ class RoboFile extends Tasks

public function someTask()
{
$this
->taskLiveReload()
->run();

// Further down...
$this
->taskLiveReload()
->sendReloadMessage();
Expand All @@ -97,6 +102,31 @@ class RoboFile extends Tasks
This will send a "reload" message to the Live Reload server. If you load the `livereload.js` file created by the task, your browser will automatically reload when this message is received.
Typically, you will use this method when using a "watch" behavior so a reload can be triggered after your watch handler has been executed.

If you want to send another message to extend the behavior of the Live Reload server, you can have access to the WebSocket client using the `getWsClient()` method and send the message you want :

```php
use Elephfront\RoboLiveReload\Task\Loader\LoadLiveReloadTaskTrait;

class RoboFile extends Tasks
{

use LoadLiveReloadTaskTrait;

public function someTask()
{
$this
->taskLiveReload()
->run();

// Further down...
$this
->taskLiveReload()
->getWsClient()
->send('your-message');
}
}
```

## Contributing

If you find a bug or would like to ask for a feature, please use the [GitHub issue tracker](https://github.com/Elephfront/robo-live-reload/issues).
Expand Down

0 comments on commit 32a377e

Please sign in to comment.