Skip to content

Commit 32a377e

Browse files
Add a note about how to get access to the WebSocket client
1 parent 399453d commit 32a377e

File tree

1 file changed

+30
-0
lines changed

1 file changed

+30
-0
lines changed

README.md

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,11 @@ class RoboFile extends Tasks
8787

8888
public function someTask()
8989
{
90+
$this
91+
->taskLiveReload()
92+
->run();
93+
94+
// Further down...
9095
$this
9196
->taskLiveReload()
9297
->sendReloadMessage();
@@ -97,6 +102,31 @@ class RoboFile extends Tasks
97102
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.
98103
Typically, you will use this method when using a "watch" behavior so a reload can be triggered after your watch handler has been executed.
99104

105+
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 :
106+
107+
```php
108+
use Elephfront\RoboLiveReload\Task\Loader\LoadLiveReloadTaskTrait;
109+
110+
class RoboFile extends Tasks
111+
{
112+
113+
use LoadLiveReloadTaskTrait;
114+
115+
public function someTask()
116+
{
117+
$this
118+
->taskLiveReload()
119+
->run();
120+
121+
// Further down...
122+
$this
123+
->taskLiveReload()
124+
->getWsClient()
125+
->send('your-message');
126+
}
127+
}
128+
```
129+
100130
## Contributing
101131

102132
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).

0 commit comments

Comments
 (0)