@@ -41,16 +41,14 @@ Once [installed](#install), you can use the following code to create a simple
41
41
echo server that listens for incoming multicast messages:
42
42
43
43
``` php
44
- $loop = React\EventLoop\Factory::create();
45
- $factory = new Factory($loop);
44
+ $factory = new Clue\React\Multicast\Factory();
46
45
$socket = $factory->createReceiver('224.10.20.30:4050');
47
46
48
47
$socket->on('message', function ($data, $remote) use ($socket) {
49
48
echo 'Sending back ' . strlen($data) . ' bytes to ' . $remote . PHP_EOL;
50
49
$socket->send($data, $remote);
51
50
});
52
51
53
- $loop->run();
54
52
```
55
53
56
54
See also the [ examples] ( examples ) .
@@ -60,13 +58,17 @@ See also the [examples](examples).
60
58
### Factory
61
59
62
60
The ` Factory ` is responsible for creating your [ ` SocketInterface ` ] ( #socketinterface ) instances.
63
- It also registers everything with the main [ ` EventLoop ` ] ( https://github.com/reactphp/event-loop#usage ) .
64
61
65
62
``` php
66
- $loop = React\EventLoop\Factory::create();
67
- $factory = new Factory($loop);
63
+ $factory = new Clue\React\Multicast\Factory();
68
64
```
69
65
66
+ This class takes an optional ` LoopInterface|null $loop ` parameter that can be used to
67
+ pass the event loop instance to use for this object. You can use a ` null ` value
68
+ here in order to use the [ default loop] ( https://github.com/reactphp/event-loop#loop ) .
69
+ This value SHOULD NOT be given unless you're sure you want to explicitly use a
70
+ given event loop instance.
71
+
70
72
#### createSender()
71
73
72
74
The ` createSender(): SocketInterface ` method can be used to
0 commit comments