Skip to content

Commit

Permalink
Merge pull request #164 from Textalk/v1.6-master
Browse files Browse the repository at this point in the history
V1.6 preview
  • Loading branch information
sirn-se authored Nov 1, 2022
2 parents d05dbaa + 0b22122 commit fc1390a
Show file tree
Hide file tree
Showing 45 changed files with 1,770 additions and 833 deletions.
54 changes: 19 additions & 35 deletions .github/workflows/acceptance.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,42 +3,12 @@ name: Acceptance
on: [push, pull_request]

jobs:
test-7-2:
runs-on: ubuntu-latest
name: Test PHP 7.2
steps:
- name: Checkout
uses: actions/checkout@v2
- name: Set up PHP 7.2
uses: shivammathur/setup-php@v2
with:
php-version: '7.2'
- name: Composer
run: make install
- name: Test
run: make test

test-7-3:
runs-on: ubuntu-latest
name: Test PHP 7.3
steps:
- name: Checkout
uses: actions/checkout@v2
- name: Set up PHP 7.3
uses: shivammathur/setup-php@v2
with:
php-version: '7.3'
- name: Composer
run: make install
- name: Test
run: make test

test-7-4:
runs-on: ubuntu-latest
name: Test PHP 7.4
steps:
- name: Checkout
uses: actions/checkout@v2
uses: actions/checkout@v3
- name: Set up PHP 7.4
uses: shivammathur/setup-php@v2
with:
Expand All @@ -53,7 +23,7 @@ jobs:
name: Test PHP 8.0
steps:
- name: Checkout
uses: actions/checkout@v2
uses: actions/checkout@v3
- name: Set up PHP 8.0
uses: shivammathur/setup-php@v2
with:
Expand All @@ -68,7 +38,7 @@ jobs:
name: Test PHP 8.1
steps:
- name: Checkout
uses: actions/checkout@v2
uses: actions/checkout@v3
- name: Set up PHP 8.1
uses: shivammathur/setup-php@v2
with:
Expand All @@ -78,13 +48,27 @@ jobs:
- name: Test
run: make test

test-8-2:
runs-on: ubuntu-latest
name: Test PHP 8.2
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Set up PHP 8.2
uses: shivammathur/setup-php@v2
with:
php-version: '8.2'
- name: Composer
run: make install
- name: Test
run: make test

cs-check:
runs-on: ubuntu-latest
name: Code standard
steps:
- name: Checkout
uses: actions/checkout@v2
uses: actions/checkout@v3
- name: Set up PHP 8.0
uses: shivammathur/setup-php@v2
with:
Expand All @@ -99,7 +83,7 @@ jobs:
name: Code coverage
steps:
- name: Checkout
uses: actions/checkout@v2
uses: actions/checkout@v3
- name: Set up PHP 8.0
uses: shivammathur/setup-php@v2
with:
Expand Down
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ test: composer.lock
./vendor/bin/phpunit

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

coverage: composer.lock build
XDEBUG_MODE=coverage ./vendor/bin/phpunit --coverage-clover build/logs/clover.xml
Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ It does not include convenience operations such as listeners and implicit error

- [Client](docs/Client.md)
- [Server](docs/Server.md)
- [Message](docs/Message.md)
- [Examples](docs/Examples.md)
- [Changelog](docs/Changelog.md)
- [Contributing](docs/Contributing.md)
Expand All @@ -24,7 +23,8 @@ Preferred way to install is with [Composer](https://getcomposer.org/).
composer require textalk/websocket
```

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

Expand Down
10 changes: 0 additions & 10 deletions codestandard.xml

This file was deleted.

12 changes: 7 additions & 5 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,7 @@
"name": "Fredrik Liljegren"
},
{
"name": "Sören Jensen",
"email": "[email protected]"
"name": "Sören Jensen"
}
],
"autoload": {
Expand All @@ -23,11 +22,14 @@
}
},
"require": {
"php": "^7.2 | ^8.0",
"psr/log": "^1 | ^2 | ^3"
"php": "^7.4 | ^8.0",
"phrity/net-uri": "^1.0",
"phrity/util-errorhandler": "^1.0",
"psr/log": "^1.0 | ^2.0 | ^3.0",
"psr/http-message": "^1.0"
},
"require-dev": {
"phpunit/phpunit": "^8.0|^9.0",
"phpunit/phpunit": "^9.0",
"php-coveralls/php-coveralls": "^2.0",
"squizlabs/php_codesniffer": "^3.5"
}
Expand Down
12 changes: 12 additions & 0 deletions docs/Changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,18 @@

# Websocket: Changelog

## `v1.6`

> PHP version `^7.4|^8.0`
### `1.6.0`
* Connection separate from Client and Server (@sirn-se)
* getPier() deprecated, replaced by getRemoteName() (@sirn-se)
* Client accepts `Psr\Http\Message\UriInterface` as input for URI:s (@sirn-se)
* Bad URI throws exception when Client is instanciated, previously when used (@sirn-se)
* Preparations for multiple conection and listeners (@sirn-se)
* Major internal refactoring (@sirn-se)

## `v1.5`

> PHP version `^7.2|^8.0`
Expand Down
42 changes: 21 additions & 21 deletions docs/Client.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,27 +10,27 @@ It internally supports Upgrade handshake and implicit close and ping/pong operat
```php
WebSocket\Client {

public __construct(string $uri, array $options = [])
public __destruct()
public __toString() : string

public text(string $payload) : void
public binary(string $payload) : void
public ping(string $payload = '') : void
public pong(string $payload = '') : void
public send(mixed $payload, string $opcode = 'text', bool $masked = true) : void
public receive() : mixed
public close(int $status = 1000, mixed $message = 'ttfn') : mixed

public getName() : string|null
public getPier() : string|null
public getLastOpcode() : string
public getCloseStatus() : int
public isConnected() : bool
public setTimeout(int $seconds) : void
public setFragmentSize(int $fragment_size) : self
public getFragmentSize() : int
public setLogger(Psr\Log\LoggerInterface $logger = null) : void
public __construct(UriInterface|string $uri, array $options = []);
public __destruct();
public __toString() : string;

public text(string $payload) : void;
public binary(string $payload) : void;
public ping(string $payload = '') : void;
public pong(string $payload = '') : void;
public send(Message|string $payload, string $opcode = 'text', bool $masked = true) : void;
public close(int $status = 1000, mixed $message = 'ttfn') : void;
public receive() : Message|string|null;

public getName() : string|null;
public getRemoteName() : string|null;
public getLastOpcode() : string;
public getCloseStatus() : int;
public isConnected() : bool;
public setTimeout(int $seconds) : void;
public setFragmentSize(int $fragment_size) : self;
public getFragmentSize() : int;
public setLogger(Psr\Log\LoggerInterface $logger = null) : void;
}
```

Expand Down
7 changes: 7 additions & 0 deletions docs/Contributing.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,13 @@ Requirements on pull requests;
* Code coverage **MUST** remain at 100%.
* Code **MUST** adhere to PSR-1 and PSR-12 code standards.

Base your patch on corresponding version branch, and target that version branch in your pull request.

* `v1.6-master` current version
* `v1.5-master` previous version, bug fixes only
* Older versions should not be target of pull requests


## Dependency management

Install or update dependencies using [Composer](https://getcomposer.org/).
Expand Down
9 changes: 6 additions & 3 deletions docs/Examples.md
Original file line number Diff line number Diff line change
Expand Up @@ -65,10 +65,13 @@ php examples/echoserver.php --debug // Use runtime debugging
```

These strings can be sent as message to trigger server to perform actions;
* `exit` - Server will initiate close procedure
* `ping` - Server will send a ping message
* `headers` - Server will respond with all headers provided by client
* `auth` - Server will respond with auth header if provided by client
* `close` - Server will close current connection
* `exit` - Server will close all active connections
* `headers` - Server will respond with all headers provided by client
* `ping` - Server will send a ping message
* `pong` - Server will send a pong message
* `stop` - Server will stop listening
* For other sent strings, server will respond with the same strings

## The `random` client
Expand Down
20 changes: 10 additions & 10 deletions docs/Message.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,22 +14,22 @@ Available classes correspond to opcode;

Additionally;
* WebSocket\Message\Message - abstract base class for all messages above
* WebSocket\Message\Factory - Factory class to create Msssage instances
* WebSocket\Message\Factory - Factory class to create Message instances

## Message abstract class synopsis

```php
WebSocket\Message\Message {

public __construct(string $payload = '')
public __toString() : string
public __construct(string $payload = '');
public __toString() : string;

public getOpcode() : string
public getLength() : int
public getTimestamp() : DateTime
public getContent() : string
public setContent(string $payload = '') : void
public hasContent() : bool
public getOpcode() : string;
public getLength() : int;
public getTimestamp() : DateTime;
public getContent() : string;
public setContent(string $payload = '') : void;
public hasContent() : bool;
}
```

Expand All @@ -38,7 +38,7 @@ WebSocket\Message\Message {
```php
WebSocket\Message\Factory {

public create(string $opcode, string $payload = '') : Message
public create(string $opcode, string $payload = '') : Message;
}
```

Expand Down
56 changes: 28 additions & 28 deletions docs/Server.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,33 +13,33 @@ If you require this kind of server behavior, you need to build it on top of prov
```php
WebSocket\Server {

public __construct(array $options = [])
public __destruct()
public __toString() : string

public accept() : bool
public text(string $payload) : void
public binary(string $payload) : void
public ping(string $payload = '') : void
public pong(string $payload = '') : void
public send(mixed $payload, string $opcode = 'text', bool $masked = true) : void
public receive() : mixed
public close(int $status = 1000, mixed $message = 'ttfn') : mixed

public getPort() : int
public getPath() : string
public getRequest() : array
public getHeader(string $header_name) : string|null

public getName() : string|null
public getPier() : string|null
public getLastOpcode() : string
public getCloseStatus() : int
public isConnected() : bool
public setTimeout(int $seconds) : void
public setFragmentSize(int $fragment_size) : self
public getFragmentSize() : int
public setLogger(Psr\Log\LoggerInterface $logger = null) : void
public __construct(array $options = []);
public __destruct();
public __toString() : string;

public accept() : bool;
public text(string $payload) : void;
public binary(string $payload) : void;
public ping(string $payload = '') : void;
public pong(string $payload = '') : void;
public send(Message|string $payload, string $opcode = 'text', bool $masked = true) : void;
public close(int $status = 1000, mixed $message = 'ttfn') : void;
public receive() : Message|string|null;

public getPort() : int;
public getPath() : string;
public getRequest() : array;
public getHeader(string $header_name) : string|null;

public getName() : string|null;
public getRemoteName() : string|null;
public getLastOpcode() : string;
public getCloseStatus() : int;
public isConnected() : bool;
public setTimeout(int $seconds) : void;
public setFragmentSize(int $fragment_size) : self;
public getFragmentSize() : int;
public setLogger(Psr\Log\LoggerInterface $logger = null) : void;
}
```

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

0 comments on commit fc1390a

Please sign in to comment.