Skip to content

Commit

Permalink
refactor: change name to octamp
Browse files Browse the repository at this point in the history
  • Loading branch information
cydrickn committed Feb 9, 2023
1 parent a13d555 commit edcaa2c
Show file tree
Hide file tree
Showing 29 changed files with 108 additions and 103 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
composer.phar
/vendor/
/build/
/examples/
.phpunit.result.cache
.phpunit.cache
Expand Down
22 changes: 11 additions & 11 deletions README.md
Original file line number Diff line number Diff line change
@@ -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

Expand All @@ -23,17 +23,17 @@ The name SWamp is from Swoole + WAMP
## Installation

```sh
composer require swamp/client
composer require octamp/client
```

## Example

```php
<?php

use SWamp\Client\Auth\WampcraAuthenticator;
use SWamp\Client\Peer;
use SWamp\Client\Session;
use Octamp\Client\Auth\WampcraAuthenticator;
use Octamp\Client\Peer;
use Octamp\Client\Session;

require_once __DIR__ . '/../../vendor/autoload.php';

Expand All @@ -46,11 +46,11 @@ $client->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;
Expand Down
1 change: 1 addition & 0 deletions bin/phpunit.php
100644 → 100755
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
#!/usr/bin/env php
<?php


Expand Down
9 changes: 6 additions & 3 deletions composer.json
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
{
"name": "swamp/client",
"name": "octamp/client",
"description": "WAMP client for PHP Swoole",
"license": "MIT",
"autoload": {
"psr-4": {
"SWamp\\Client\\": "src/",
"SWamp\\Client\\Tests\\": "tests/"
"Octamp\\Client\\": "src/",
"Octamp\\Client\\Tests\\": "tests/"
},
"files": ["src/helpers.php"]
},
Expand All @@ -23,5 +23,8 @@
"require": {
"php": ">=8.1",
"voryx/thruway-common": "^1.0"
},
"scripts": {
"test": "./bin/phpunit.php"
}
}
2 changes: 1 addition & 1 deletion src/Auth/WampcraAuthenticator.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php

namespace SWamp\Client\Auth;
namespace Octamp\Client\Auth;

use Thruway\Message\ChallengeMessage;
use Thruway\Message\AuthenticateMessage;
Expand Down
2 changes: 1 addition & 1 deletion src/EventDispatcher.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php

namespace SWamp\Client;
namespace Octamp\Client;

use Swoole\Coroutine;

Expand Down
14 changes: 7 additions & 7 deletions src/Peer.php
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
<?php

namespace SWamp\Client;
namespace Octamp\Client;

use Co\Http\Client as SwooleClient;
use SWamp\Client\Roles\AbstractRole;
use SWamp\Client\Roles\Callee;
use SWamp\Client\Roles\Caller;
use SWamp\Client\Roles\Publisher;
use SWamp\Client\Roles\Subscriber;
use Octamp\Client\Roles\AbstractRole;
use Octamp\Client\Roles\Callee;
use Octamp\Client\Roles\Caller;
use Octamp\Client\Roles\Publisher;
use Octamp\Client\Roles\Subscriber;
use Swoole\Coroutine;
use Swoole\WebSocket\Frame;
use Thruway\Message\AbortMessage;
Expand Down Expand Up @@ -73,7 +73,7 @@ public function open(): void
});
}

protected function startSession()
protected function startSession(): void
{
$this->roles['publisher'] = new Publisher();
$this->roles['subscriber'] = new Subscriber();
Expand Down
2 changes: 1 addition & 1 deletion src/Promise/CancellablePromiseInterface.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php

namespace SWamp\Client\Promise;
namespace Octamp\Client\Promise;

interface CancellablePromiseInterface extends PromiseInterface
{
Expand Down
2 changes: 1 addition & 1 deletion src/Promise/Deferred.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php

namespace SWamp\Client\Promise;
namespace Octamp\Client\Promise;

class Deferred
{
Expand Down
2 changes: 1 addition & 1 deletion src/Promise/ProgressPromise.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php

namespace SWamp\Client\Promise;
namespace Octamp\Client\Promise;

use Swoole\Coroutine;

Expand Down
2 changes: 1 addition & 1 deletion src/Promise/ProgressablePromiseInterface.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php

namespace SWamp\Client\Promise;
namespace Octamp\Client\Promise;

interface ProgressablePromiseInterface extends PromiseInterface
{
Expand Down
2 changes: 1 addition & 1 deletion src/Promise/Promise.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php

namespace SWamp\Client\Promise;
namespace Octamp\Client\Promise;

use Co\Channel;
use Swoole\ArrayObject;
Expand Down
2 changes: 1 addition & 1 deletion src/Promise/PromiseInterface.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php

namespace SWamp\Client\Promise;
namespace Octamp\Client\Promise;

interface PromiseInterface
{
Expand Down
2 changes: 1 addition & 1 deletion src/Result.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php

namespace SWamp\Client;
namespace Octamp\Client;

class Result
{
Expand Down
4 changes: 2 additions & 2 deletions src/Roles/AbstractRole.php
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
<?php

namespace SWamp\Client\Roles;
namespace Octamp\Client\Roles;

use SWamp\Client\Session;
use Octamp\Client\Session;
use Thruway\Message\Message;

abstract class AbstractRole
Expand Down
20 changes: 10 additions & 10 deletions src/Roles/Callee.php
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
<?php

namespace SWamp\Client\Roles;

use SWamp\Client\Peer;
use SWamp\Client\Promise\CancellablePromiseInterface;
use SWamp\Client\Promise\Deferred;
use SWamp\Client\Promise\ProgressablePromiseInterface;
use SWamp\Client\Promise\ProgressPromise;
use SWamp\Client\Promise\PromiseInterface;
use SWamp\Client\Result;
use SWamp\Client\Session;
namespace Octamp\Client\Roles;

use Octamp\Client\Peer;
use Octamp\Client\Promise\CancellablePromiseInterface;
use Octamp\Client\Promise\Deferred;
use Octamp\Client\Promise\ProgressablePromiseInterface;
use Octamp\Client\Promise\ProgressPromise;
use Octamp\Client\Promise\PromiseInterface;
use Octamp\Client\Result;
use Octamp\Client\Session;
use Thruway\Common\Utils;
use Thruway\Message\ErrorMessage;
use Thruway\Message\InterruptMessage;
Expand Down
12 changes: 6 additions & 6 deletions src/Roles/Caller.php
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
<?php

namespace SWamp\Client\Roles;
namespace Octamp\Client\Roles;

use SWamp\Client\Promise\Deferred;
use SWamp\Client\Promise\ProgressablePromiseInterface;
use SWamp\Client\Promise\ProgressPromise;
use SWamp\Client\Result;
use SWamp\Client\Session;
use Octamp\Client\Promise\Deferred;
use Octamp\Client\Promise\ProgressablePromiseInterface;
use Octamp\Client\Promise\ProgressPromise;
use Octamp\Client\Result;
use Octamp\Client\Session;
use Thruway\Common\Utils;
use Thruway\Message\CallMessage;
use Thruway\Message\ErrorMessage;
Expand Down
8 changes: 4 additions & 4 deletions src/Roles/Publisher.php
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
<?php

namespace SWamp\Client\Roles;
namespace Octamp\Client\Roles;

use SWamp\Client\Promise\Deferred;
use SWamp\Client\Promise\PromiseInterface;
use SWamp\Client\Session;
use Octamp\Client\Promise\Deferred;
use Octamp\Client\Promise\PromiseInterface;
use Octamp\Client\Session;
use Thruway\Common\Utils;
use Thruway\Message\ErrorMessage;
use Thruway\Message\Message;
Expand Down
6 changes: 3 additions & 3 deletions src/Roles/Subscriber.php
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
<?php

namespace SWamp\Client\Roles;
namespace Octamp\Client\Roles;

use SWamp\Client\Promise\Deferred;
use SWamp\Client\Session;
use Octamp\Client\Promise\Deferred;
use Octamp\Client\Session;
use Thruway\Common\Utils;
use Thruway\Message\ErrorMessage;
use Thruway\Message\EventMessage;
Expand Down
4 changes: 2 additions & 2 deletions src/Session.php
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
<?php

namespace SWamp\Client;
namespace Octamp\Client;

use SWamp\Client\Promise\PromiseInterface;
use Octamp\Client\Promise\PromiseInterface;
use Thruway\Message\Message;

class Session
Expand Down
6 changes: 3 additions & 3 deletions src/helpers.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@

function await(mixed $callback): mixed
{
return (new \SWamp\Client\Promise\Promise($callback))->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);
}
2 changes: 1 addition & 1 deletion tests/AssertCoroutine.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php

namespace SWamp\Client\Tests;
namespace Octamp\Client\Tests;

class AssertCoroutine
{
Expand Down
6 changes: 3 additions & 3 deletions tests/Unit/Auth/WampcraAuthenticatorTest.php
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
<?php

namespace SWamp\Client\Tests\Unit\Auth;
namespace Octamp\Client\Tests\Unit\Auth;

use SWamp\Client\Auth\WampcraAuthenticator;
use SWamp\Client\Tests\Unit\TestCase;
use Octamp\Client\Auth\WampcraAuthenticator;
use Octamp\Client\Tests\Unit\TestCase;
use Thruway\Message\AuthenticateMessage;
use Thruway\Message\ChallengeMessage;

Expand Down
18 changes: 9 additions & 9 deletions tests/Unit/Promise/DeferredTest.php
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
<?php

namespace SWamp\Client\Tests\Unit\Auth;
namespace Octamp\Client\Tests\Unit\Auth;

use Co\Scheduler;
use Co\WaitGroup;
use SWamp\Client\Promise\Deferred;
use SWamp\Client\Promise\ProgressablePromiseInterface;
use SWamp\Client\Tests\AssertCoroutine;
use SWamp\Client\Tests\Unit\TestCase;
use Octamp\Client\Promise\Deferred;
use Octamp\Client\Promise\ProgressablePromiseInterface;
use Octamp\Client\Tests\AssertCoroutine;
use Octamp\Client\Tests\Unit\TestCase;
use Swoole\Coroutine;

class DeferredTest extends TestCase
Expand All @@ -18,10 +18,10 @@ public function testResolve()
$this->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()
Expand All @@ -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()
Expand Down
10 changes: 5 additions & 5 deletions tests/Unit/Promise/ProgressPromiseTest.php
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
<?php

namespace SWamp\Client\Tests\Unit\Auth;
namespace Octamp\Client\Tests\Unit\Auth;

use SWamp\Client\Promise\ProgressPromise;
use SWamp\Client\Promise\Promise;
use SWamp\Client\Tests\AssertCoroutine;
use SWamp\Client\Tests\Unit\TestCase;
use Octamp\Client\Promise\ProgressPromise;
use Octamp\Client\Promise\Promise;
use Octamp\Client\Tests\AssertCoroutine;
use Octamp\Client\Tests\Unit\TestCase;

class ProgressPromiseTest extends TestCase
{
Expand Down
Loading

0 comments on commit edcaa2c

Please sign in to comment.