You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+34-5Lines changed: 34 additions & 5 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -15,14 +15,44 @@ Supported functions:
15
15
16
16
## Usage
17
17
18
+
### Directly Create A Client
19
+
20
+
You can directly create a `Gos\Component\WebSocketClient\Wamp\ClientInterface` instance by creating a new `Gos\Component\WebSocketClient\Wamp\Client` object. The constructor has two mandatory requirements; the server host and port. You may review the [`Client class constructor`](/src/Wamp/Client.php) to see all arguments.
21
+
18
22
```php
23
+
<?php
19
24
use Gos\Component\WebSocketClient\Wamp\Client;
20
25
21
-
$client = new Client('127.0.0.1', '8080');
26
+
$client = new Client('127.0.0.1', 8080);
27
+
```
28
+
29
+
### Through The Factory
30
+
31
+
A `Gos\Component\WebSocketClient\Wamp\ClientFactoryInterface` is available to create client instances as well. The default `Gos\Component\WebSocketClient\Wamp\ClientFactory` supports a PSR-3 logger and will automatically inject it into the client if one is present.
32
+
33
+
```php
34
+
<?php
35
+
use Gos\Component\WebSocketClient\Wamp\ClientFactory;
36
+
37
+
$factory = new ClientFactory(['host' => '127.0.0.1', 'port' => 8080]);
38
+
$client = $factory->createConnection();
39
+
```
40
+
41
+
### Interact With Server
42
+
43
+
Once you have created a client, you can connect and interact with your websocket server.
44
+
45
+
```php
46
+
<?php
47
+
use Gos\Component\WebSocketClient\Wamp\ClientFactory;
48
+
49
+
$factory = new ClientFactory(['host' => '127.0.0.1', 'port' => 8080]);
0 commit comments