diff --git a/.gitignore b/.gitignore index f75dc21..ec36acc 100644 --- a/.gitignore +++ b/.gitignore @@ -1,5 +1,6 @@ composer.phar /vendor/ +/build/ /examples/ .phpunit.result.cache .phpunit.cache diff --git a/README.md b/README.md index 13d28ab..55d0b55 100644 --- a/README.md +++ b/README.md @@ -1,11 +1,11 @@ -# SWamp Client -SWamp Client is an open source client for [WAMP (Web Application Messaging Protocol)](https://wamp-proto.org/), for PHP. +# Octamp Client +Octamp Client is an open source client for [WAMP (Web Application Messaging Protocol)](https://wamp-proto.org/), for PHP. -SWamp Client uses [Open Swoole](https://openswoole.com/docs), is a high-performance network framework based on an event-driven, asynchronous, non-blocking I/O coroutine programming model for PHP. +Octamp Client uses [Open Swoole](https://openswoole.com/docs), is a high-performance network framework based on an event-driven, asynchronous, non-blocking I/O coroutine programming model for PHP. -We also design the SWamp Client functions to be identical to [AutobahnJS](https://github.com/crossbario/autobahn-js) +We also design the Octamp Client functions to be identical to [AutobahnJS](https://github.com/crossbario/autobahn-js) -The name SWamp is from Swoole + WAMP +The name Octamp is from Octopus + WAMP ## Supported WAMP Features @@ -23,7 +23,7 @@ The name SWamp is from Swoole + WAMP ## Installation ```sh -composer require swamp/client +composer require octamp/client ``` ## Example @@ -31,9 +31,9 @@ composer require swamp/client ```php onOpen(function (Session $session) { }); // publish - $session->publish('hello', ['hello swamp'], [], ['exclude_me' => false]); + $session->publish('hello', ['hello octamp'], [], ['exclude_me' => false]); // publish with acknowledgement $session - ->publish('hello', ['hello swamp with acknowledgement'], [], ['acknowledge' => true, 'exclude_me' => false]) + ->publish('hello', ['hello octamp with acknowledgement'], [], ['acknowledge' => true, 'exclude_me' => false]) ->then( function () { echo 'Publish Acknowledged!' . PHP_EOL; diff --git a/bin/phpunit.php b/bin/phpunit.php old mode 100644 new mode 100755 index 65d2adc..fe8bb6a --- a/bin/phpunit.php +++ b/bin/phpunit.php @@ -1,3 +1,4 @@ +#!/usr/bin/env php =8.1", "voryx/thruway-common": "^1.0" + }, + "scripts": { + "test": "./bin/phpunit.php" } } diff --git a/src/Auth/WampcraAuthenticator.php b/src/Auth/WampcraAuthenticator.php index f4cec6e..3bd4b07 100644 --- a/src/Auth/WampcraAuthenticator.php +++ b/src/Auth/WampcraAuthenticator.php @@ -1,6 +1,6 @@ roles['publisher'] = new Publisher(); $this->roles['subscriber'] = new Subscriber(); diff --git a/src/Promise/CancellablePromiseInterface.php b/src/Promise/CancellablePromiseInterface.php index c9ca3fb..33609b9 100644 --- a/src/Promise/CancellablePromiseInterface.php +++ b/src/Promise/CancellablePromiseInterface.php @@ -1,6 +1,6 @@ wait(); + return (new \Octamp\Client\Promise\Promise($callback))->wait(); } -function promise(callable $callback): \SWamp\Client\Promise\Promise +function promise(callable $callback): \Octamp\Client\Promise\Promise { - return new \SWamp\Client\Promise\Promise($callback); + return new \Octamp\Client\Promise\Promise($callback); } diff --git a/tests/AssertCoroutine.php b/tests/AssertCoroutine.php index 052d4a0..cca9015 100644 --- a/tests/AssertCoroutine.php +++ b/tests/AssertCoroutine.php @@ -1,6 +1,6 @@ assertInstanceOf(ProgressablePromiseInterface::class, $deferred->promise()); $promise = $deferred->promise(); - $deferred->resolve('hello swamp'); + $deferred->resolve('hello Octamp'); $result = $promise->wait(); - $this->assertSame('hello swamp', $result); + $this->assertSame('hello Octamp', $result); } public function testReject() @@ -30,10 +30,10 @@ public function testReject() $this->assertInstanceOf(ProgressablePromiseInterface::class, $deferred->promise()); $promise = $deferred->promise(); - $deferred->reject('hello swamp'); + $deferred->reject('hello Octamp'); $result = $promise->wait(); - $this->assertSame('hello swamp', $result); + $this->assertSame('hello Octamp', $result); } public function testProgress() diff --git a/tests/Unit/Promise/ProgressPromiseTest.php b/tests/Unit/Promise/ProgressPromiseTest.php index 28cf80b..24fcf4b 100644 --- a/tests/Unit/Promise/ProgressPromiseTest.php +++ b/tests/Unit/Promise/ProgressPromiseTest.php @@ -1,11 +1,11 @@ then(); $promise->then(function ($data) use (&$assert) { - $assert->add([$this, 'assertSame'], 'hello swamp', $data); + $assert->add([$this, 'assertSame'], 'hello octamp', $data); }); $assert->assert(); @@ -31,11 +31,11 @@ public function testPromiseReject() $assert = new AssertCoroutine(); $promise = new Promise(function ($resolve, $reject) { - $reject('hello swamp'); + $reject('hello octamp'); }); $promise->then(function () { }, function ($data) use (&$assert) { - $assert->add([$this, 'assertSame'], 'hello swamp', $data); + $assert->add([$this, 'assertSame'], 'hello octamp', $data); }); $assert->assert(); @@ -46,10 +46,10 @@ public function testCatch() $assert = new AssertCoroutine(); $promise = new Promise(function ($resolve, $reject) { - $reject('hello swamp'); + $reject('hello octamp'); }); $promise->catch(function ($data) use (&$assert) { - $assert->add([$this, 'assertSame'], 'hello swamp', $data); + $assert->add([$this, 'assertSame'], 'hello octamp', $data); }); $assert->assert(); @@ -109,10 +109,10 @@ public function testPromiseWait() { $promise = new Promise(function ($resolve) { usleep(100); - $resolve('hello swamp'); + $resolve('hello octamp'); }); $result = $promise->wait(); - $this->assertSame('hello swamp', $result); + $this->assertSame('hello octamp', $result); } } diff --git a/tests/Unit/ResultTest.php b/tests/Unit/ResultTest.php index 8084c0d..bd9c892 100644 --- a/tests/Unit/ResultTest.php +++ b/tests/Unit/ResultTest.php @@ -1,8 +1,8 @@