1
- Classes: [ Client] ( Classes/ Client.md) • Server
1
+ Classes: [ Client] ( Client.md ) • Server
2
2
3
3
# Server class
4
4
@@ -65,22 +65,22 @@ public function __construct(array $options = [])
65
65
###### ` options `
66
66
67
67
An optional array of parameters.
68
- | Name | Type | | Default | Description |
69
- | --- | --- | --- | --- [
70
- | ` filter ` | ` array ` | ` ['text', 'binary'] ` | Array of opcodes to return on receive and listen functions
71
- | ` fragment_size ` | ` int ` | ` 4096 ` | Maximum payload size
72
- | ` logger ` | ` Psr\Log\LoggerInterface ` | ` Psr\Log\NullLogger ` |A [ PSR-3] ( https://www.php-fig.org/psr/psr-3/ ) compatible logger
73
- | ` port ` | ` int ` | ` 8000 ` | The server port to listen to
74
- | ` return_obj ` | ` bool ` | ` false ` | Return a [ Message] ( Classes/ Message.md) instance on receive function
75
- | ` timeout ` | ` int ` | ` 5 ` | Time out in seconds
68
+ Name | Type | Default | Description
69
+ --- | --- | --- | ---
70
+ filter` | array | [ 'text', 'binary'] | Array of opcodes to return on receive and listen functions
71
+ fragment_size | int | 4096 | Maximum payload size
72
+ logger | Psr\Log\LoggerInterface | Psr\Log\NullLogger |A [ PSR-3] ( https://www.php-fig.org/psr/psr-3/ ) compatible logger
73
+ port | int | 8000 | The server port to listen to
74
+ return_obj | bool | false | Return a [ Message] ( Message.md ) instance on receive function
75
+ timeout | int | 5 | Time out in seconds
76
76
77
77
#### Return Values
78
78
79
79
Returns a new WebSocket\Server instance.
80
80
81
81
#### Errors/Exceptions
82
82
83
- Emits [ ConnectionException] ( Classes/ ConnectionException.md) on failure.
83
+ Emits [ ConnectionException] ( ConnectionException.md ) on failure.
84
84
85
85
#### Examples
86
86
@@ -129,8 +129,8 @@ public function listen(Closure $callback) : mixed
129
129
A callback function that is triggered whenever the server receives a message matching the filter.
130
130
131
131
The callback takes two parameters;
132
- * The [ Message] ( Classes/ Message/Message.md) that has been received
133
- * The [ Connection] ( Classes/ Connection.md) the server has receievd on, can be ` null ` if connection is closed
132
+ * The [ Message] ( Message/Message.md ) that has been received
133
+ * The [ Connection] ( Connection.md ) the server has receievd on, can be ` null ` if connection is closed
134
134
135
135
If callback function returns non-null value, the listener will halt and return that value.
136
136
Otherwise it will continue listening and propagating messages.
@@ -141,7 +141,7 @@ Returns any non-null value returned by callback function.
141
141
142
142
#### Errors/Exceptions
143
143
144
- Emits [ ConnectionException] ( Classes/ ConnectionException.md) on failure.
144
+ Emits [ ConnectionException] ( ConnectionException.md ) on failure.
145
145
146
146
#### Examples
147
147
@@ -173,7 +173,7 @@ Halt listener and return a value to calling code.
173
173
``` php
174
174
<?php
175
175
176
- $server = new WebSocket\Server(['filter' => ['text', 'binary', 'ping', 'pong', 'close']] );
176
+ $server = new WebSocket\Server();
177
177
$content = $server->listen(function ($message, $connection) {
178
178
return $message->getContent();
179
179
});
0 commit comments