Skip to content

Commit fc1390a

Browse files
authored
Merge pull request #164 from Textalk/v1.6-master
V1.6 preview
2 parents d05dbaa + 0b22122 commit fc1390a

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

45 files changed

+1770
-833
lines changed

.github/workflows/acceptance.yml

+19-35
Original file line numberDiff line numberDiff line change
@@ -3,42 +3,12 @@ name: Acceptance
33
on: [push, pull_request]
44

55
jobs:
6-
test-7-2:
7-
runs-on: ubuntu-latest
8-
name: Test PHP 7.2
9-
steps:
10-
- name: Checkout
11-
uses: actions/checkout@v2
12-
- name: Set up PHP 7.2
13-
uses: shivammathur/setup-php@v2
14-
with:
15-
php-version: '7.2'
16-
- name: Composer
17-
run: make install
18-
- name: Test
19-
run: make test
20-
21-
test-7-3:
22-
runs-on: ubuntu-latest
23-
name: Test PHP 7.3
24-
steps:
25-
- name: Checkout
26-
uses: actions/checkout@v2
27-
- name: Set up PHP 7.3
28-
uses: shivammathur/setup-php@v2
29-
with:
30-
php-version: '7.3'
31-
- name: Composer
32-
run: make install
33-
- name: Test
34-
run: make test
35-
366
test-7-4:
377
runs-on: ubuntu-latest
388
name: Test PHP 7.4
399
steps:
4010
- name: Checkout
41-
uses: actions/checkout@v2
11+
uses: actions/checkout@v3
4212
- name: Set up PHP 7.4
4313
uses: shivammathur/setup-php@v2
4414
with:
@@ -53,7 +23,7 @@ jobs:
5323
name: Test PHP 8.0
5424
steps:
5525
- name: Checkout
56-
uses: actions/checkout@v2
26+
uses: actions/checkout@v3
5727
- name: Set up PHP 8.0
5828
uses: shivammathur/setup-php@v2
5929
with:
@@ -68,7 +38,7 @@ jobs:
6838
name: Test PHP 8.1
6939
steps:
7040
- name: Checkout
71-
uses: actions/checkout@v2
41+
uses: actions/checkout@v3
7242
- name: Set up PHP 8.1
7343
uses: shivammathur/setup-php@v2
7444
with:
@@ -78,13 +48,27 @@ jobs:
7848
- name: Test
7949
run: make test
8050

51+
test-8-2:
52+
runs-on: ubuntu-latest
53+
name: Test PHP 8.2
54+
steps:
55+
- name: Checkout
56+
uses: actions/checkout@v3
57+
- name: Set up PHP 8.2
58+
uses: shivammathur/setup-php@v2
59+
with:
60+
php-version: '8.2'
61+
- name: Composer
62+
run: make install
63+
- name: Test
64+
run: make test
8165

8266
cs-check:
8367
runs-on: ubuntu-latest
8468
name: Code standard
8569
steps:
8670
- name: Checkout
87-
uses: actions/checkout@v2
71+
uses: actions/checkout@v3
8872
- name: Set up PHP 8.0
8973
uses: shivammathur/setup-php@v2
9074
with:
@@ -99,7 +83,7 @@ jobs:
9983
name: Code coverage
10084
steps:
10185
- name: Checkout
102-
uses: actions/checkout@v2
86+
uses: actions/checkout@v3
10387
- name: Set up PHP 8.0
10488
uses: shivammathur/setup-php@v2
10589
with:

Makefile

+1-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ test: composer.lock
99
./vendor/bin/phpunit
1010

1111
cs-check: composer.lock
12-
./vendor/bin/phpcs --standard=codestandard.xml lib tests examples
12+
./vendor/bin/phpcs --standard=PSR1,PSR12 --encoding=UTF-8 --report=full --colors lib tests examples
1313

1414
coverage: composer.lock build
1515
XDEBUG_MODE=coverage ./vendor/bin/phpunit --coverage-clover build/logs/clover.xml

README.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@ It does not include convenience operations such as listeners and implicit error
1212

1313
- [Client](docs/Client.md)
1414
- [Server](docs/Server.md)
15-
- [Message](docs/Message.md)
1615
- [Examples](docs/Examples.md)
1716
- [Changelog](docs/Changelog.md)
1817
- [Contributing](docs/Contributing.md)
@@ -24,7 +23,8 @@ Preferred way to install is with [Composer](https://getcomposer.org/).
2423
composer require textalk/websocket
2524
```
2625

27-
* Current version support PHP versions `^7.2|^8.0`.
26+
* Current version support PHP versions `^7.4|^8.0`.
27+
* For PHP `7.2` and `7.3` support use version [`1.5`](https://github.com/Textalk/websocket-php/tree/1.5.0).
2828
* For PHP `7.1` support use version [`1.4`](https://github.com/Textalk/websocket-php/tree/1.4.0).
2929
* For PHP `^5.4` and `7.0` support use version [`1.3`](https://github.com/Textalk/websocket-php/tree/1.3.0).
3030

codestandard.xml

-10
This file was deleted.

composer.json

+7-5
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,7 @@
88
"name": "Fredrik Liljegren"
99
},
1010
{
11-
"name": "Sören Jensen",
12-
"email": "[email protected]"
11+
"name": "Sören Jensen"
1312
}
1413
],
1514
"autoload": {
@@ -23,11 +22,14 @@
2322
}
2423
},
2524
"require": {
26-
"php": "^7.2 | ^8.0",
27-
"psr/log": "^1 | ^2 | ^3"
25+
"php": "^7.4 | ^8.0",
26+
"phrity/net-uri": "^1.0",
27+
"phrity/util-errorhandler": "^1.0",
28+
"psr/log": "^1.0 | ^2.0 | ^3.0",
29+
"psr/http-message": "^1.0"
2830
},
2931
"require-dev": {
30-
"phpunit/phpunit": "^8.0|^9.0",
32+
"phpunit/phpunit": "^9.0",
3133
"php-coveralls/php-coveralls": "^2.0",
3234
"squizlabs/php_codesniffer": "^3.5"
3335
}

docs/Changelog.md

+12
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,18 @@
22

33
# Websocket: Changelog
44

5+
## `v1.6`
6+
7+
> PHP version `^7.4|^8.0`
8+
9+
### `1.6.0`
10+
* Connection separate from Client and Server (@sirn-se)
11+
* getPier() deprecated, replaced by getRemoteName() (@sirn-se)
12+
* Client accepts `Psr\Http\Message\UriInterface` as input for URI:s (@sirn-se)
13+
* Bad URI throws exception when Client is instanciated, previously when used (@sirn-se)
14+
* Preparations for multiple conection and listeners (@sirn-se)
15+
* Major internal refactoring (@sirn-se)
16+
517
## `v1.5`
618

719
> PHP version `^7.2|^8.0`

docs/Client.md

+21-21
Original file line numberDiff line numberDiff line change
@@ -10,27 +10,27 @@ It internally supports Upgrade handshake and implicit close and ping/pong operat
1010
```php
1111
WebSocket\Client {
1212

13-
public __construct(string $uri, array $options = [])
14-
public __destruct()
15-
public __toString() : string
16-
17-
public text(string $payload) : void
18-
public binary(string $payload) : void
19-
public ping(string $payload = '') : void
20-
public pong(string $payload = '') : void
21-
public send(mixed $payload, string $opcode = 'text', bool $masked = true) : void
22-
public receive() : mixed
23-
public close(int $status = 1000, mixed $message = 'ttfn') : mixed
24-
25-
public getName() : string|null
26-
public getPier() : string|null
27-
public getLastOpcode() : string
28-
public getCloseStatus() : int
29-
public isConnected() : bool
30-
public setTimeout(int $seconds) : void
31-
public setFragmentSize(int $fragment_size) : self
32-
public getFragmentSize() : int
33-
public setLogger(Psr\Log\LoggerInterface $logger = null) : void
13+
public __construct(UriInterface|string $uri, array $options = []);
14+
public __destruct();
15+
public __toString() : string;
16+
17+
public text(string $payload) : void;
18+
public binary(string $payload) : void;
19+
public ping(string $payload = '') : void;
20+
public pong(string $payload = '') : void;
21+
public send(Message|string $payload, string $opcode = 'text', bool $masked = true) : void;
22+
public close(int $status = 1000, mixed $message = 'ttfn') : void;
23+
public receive() : Message|string|null;
24+
25+
public getName() : string|null;
26+
public getRemoteName() : string|null;
27+
public getLastOpcode() : string;
28+
public getCloseStatus() : int;
29+
public isConnected() : bool;
30+
public setTimeout(int $seconds) : void;
31+
public setFragmentSize(int $fragment_size) : self;
32+
public getFragmentSize() : int;
33+
public setLogger(Psr\Log\LoggerInterface $logger = null) : void;
3434
}
3535
```
3636

docs/Contributing.md

+7
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,13 @@ Requirements on pull requests;
1212
* Code coverage **MUST** remain at 100%.
1313
* Code **MUST** adhere to PSR-1 and PSR-12 code standards.
1414

15+
Base your patch on corresponding version branch, and target that version branch in your pull request.
16+
17+
* `v1.6-master` current version
18+
* `v1.5-master` previous version, bug fixes only
19+
* Older versions should not be target of pull requests
20+
21+
1522
## Dependency management
1623

1724
Install or update dependencies using [Composer](https://getcomposer.org/).

docs/Examples.md

+6-3
Original file line numberDiff line numberDiff line change
@@ -65,10 +65,13 @@ php examples/echoserver.php --debug // Use runtime debugging
6565
```
6666

6767
These strings can be sent as message to trigger server to perform actions;
68-
* `exit` - Server will initiate close procedure
69-
* `ping` - Server will send a ping message
70-
* `headers` - Server will respond with all headers provided by client
7168
* `auth` - Server will respond with auth header if provided by client
69+
* `close` - Server will close current connection
70+
* `exit` - Server will close all active connections
71+
* `headers` - Server will respond with all headers provided by client
72+
* `ping` - Server will send a ping message
73+
* `pong` - Server will send a pong message
74+
* `stop` - Server will stop listening
7275
* For other sent strings, server will respond with the same strings
7376

7477
## The `random` client

docs/Message.md

+10-10
Original file line numberDiff line numberDiff line change
@@ -14,22 +14,22 @@ Available classes correspond to opcode;
1414

1515
Additionally;
1616
* WebSocket\Message\Message - abstract base class for all messages above
17-
* WebSocket\Message\Factory - Factory class to create Msssage instances
17+
* WebSocket\Message\Factory - Factory class to create Message instances
1818

1919
## Message abstract class synopsis
2020

2121
```php
2222
WebSocket\Message\Message {
2323

24-
public __construct(string $payload = '')
25-
public __toString() : string
24+
public __construct(string $payload = '');
25+
public __toString() : string;
2626

27-
public getOpcode() : string
28-
public getLength() : int
29-
public getTimestamp() : DateTime
30-
public getContent() : string
31-
public setContent(string $payload = '') : void
32-
public hasContent() : bool
27+
public getOpcode() : string;
28+
public getLength() : int;
29+
public getTimestamp() : DateTime;
30+
public getContent() : string;
31+
public setContent(string $payload = '') : void;
32+
public hasContent() : bool;
3333
}
3434
```
3535

@@ -38,7 +38,7 @@ WebSocket\Message\Message {
3838
```php
3939
WebSocket\Message\Factory {
4040

41-
public create(string $opcode, string $payload = '') : Message
41+
public create(string $opcode, string $payload = '') : Message;
4242
}
4343
```
4444

docs/Server.md

+28-28
Original file line numberDiff line numberDiff line change
@@ -13,33 +13,33 @@ If you require this kind of server behavior, you need to build it on top of prov
1313
```php
1414
WebSocket\Server {
1515

16-
public __construct(array $options = [])
17-
public __destruct()
18-
public __toString() : string
19-
20-
public accept() : bool
21-
public text(string $payload) : void
22-
public binary(string $payload) : void
23-
public ping(string $payload = '') : void
24-
public pong(string $payload = '') : void
25-
public send(mixed $payload, string $opcode = 'text', bool $masked = true) : void
26-
public receive() : mixed
27-
public close(int $status = 1000, mixed $message = 'ttfn') : mixed
28-
29-
public getPort() : int
30-
public getPath() : string
31-
public getRequest() : array
32-
public getHeader(string $header_name) : string|null
33-
34-
public getName() : string|null
35-
public getPier() : string|null
36-
public getLastOpcode() : string
37-
public getCloseStatus() : int
38-
public isConnected() : bool
39-
public setTimeout(int $seconds) : void
40-
public setFragmentSize(int $fragment_size) : self
41-
public getFragmentSize() : int
42-
public setLogger(Psr\Log\LoggerInterface $logger = null) : void
16+
public __construct(array $options = []);
17+
public __destruct();
18+
public __toString() : string;
19+
20+
public accept() : bool;
21+
public text(string $payload) : void;
22+
public binary(string $payload) : void;
23+
public ping(string $payload = '') : void;
24+
public pong(string $payload = '') : void;
25+
public send(Message|string $payload, string $opcode = 'text', bool $masked = true) : void;
26+
public close(int $status = 1000, mixed $message = 'ttfn') : void;
27+
public receive() : Message|string|null;
28+
29+
public getPort() : int;
30+
public getPath() : string;
31+
public getRequest() : array;
32+
public getHeader(string $header_name) : string|null;
33+
34+
public getName() : string|null;
35+
public getRemoteName() : string|null;
36+
public getLastOpcode() : string;
37+
public getCloseStatus() : int;
38+
public isConnected() : bool;
39+
public setTimeout(int $seconds) : void;
40+
public setFragmentSize(int $fragment_size) : self;
41+
public getFragmentSize() : int;
42+
public setLogger(Psr\Log\LoggerInterface $logger = null) : void;
4343
}
4444
```
4545

@@ -124,7 +124,7 @@ $server = new WebSocket\Server([
124124
'filter' => ['text', 'binary', 'ping'], // Specify message types for receive() to return
125125
'logger' => $my_psr3_logger, // Attach a PSR3 compatible logger
126126
'port' => 9000, // Listening port
127-
'return_obj' => true, // Return Message insatnce rather than just text
127+
'return_obj' => true, // Return Message instance rather than just text
128128
'timeout' => 60, // 1 minute time out
129129
]);
130130
```

0 commit comments

Comments
 (0)