-
Notifications
You must be signed in to change notification settings - Fork 437
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
c8af9e2
commit b8f0453
Showing
4 changed files
with
82 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -66,6 +66,7 @@ remote async-event-dispatcher [email protected]:php-enqueue/async-event-dispatcher. | |
remote async-command [email protected]:php-enqueue/async-command.git | ||
remote mongodb [email protected]:php-enqueue/mongodb.git | ||
remote dsn [email protected]:php-enqueue/dsn.git | ||
remote wamp [email protected]:php-enqueue/wamp.git | ||
|
||
split 'pkg/enqueue' enqueue | ||
split 'pkg/simple-client' simple-client | ||
|
@@ -90,3 +91,4 @@ split 'pkg/async-event-dispatcher' async-event-dispatcher | |
split 'pkg/async-command' async-command | ||
split 'pkg/mongodb' mongodb | ||
split 'pkg/dsn' dsn | ||
split 'pkg/wamp' wamp |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,73 @@ | ||
# Web Application Messaging Protocol (WAMP) Transport | ||
|
||
A transport for [Web Application Messaging Protocol](https://wamp-proto.org/). | ||
WAMP is an open standard WebSocket subprotocol. | ||
It uses internally Thruway PHP library [voryx/thruway](https://github.com/voryx/Thruway) | ||
|
||
* [Installation](#installation) | ||
* [Start the WAMP router](#start-the-wamp-router) | ||
* [Create context](#create-context) | ||
* [Consume message](#consume-message) | ||
* [Send message to topic](#send-message-to-topic) | ||
|
||
## Installation | ||
|
||
```bash | ||
$ composer require enqueue/wamp | ||
``` | ||
|
||
## Start the WAMP router | ||
|
||
```bash | ||
$ php vendor/voryx/thruway/Examples/SimpleWsRouter.php | ||
``` | ||
|
||
Thruway is now running on 127.0.0.1 port 9090 | ||
|
||
|
||
## Create context | ||
|
||
```php | ||
<?php | ||
use Enqueue\Wamp\WampConnectionFactory; | ||
|
||
$connectionFactory = new WampConnectionFactory(); | ||
|
||
$context = $connectionFactory->createContext(); | ||
|
||
// if you have enqueue/enqueue library installed you can use a factory to build context from DSN | ||
$context = (new \Enqueue\ConnectionFactoryFactory())->create('wamp:')->createContext(); | ||
``` | ||
|
||
## Consume message: | ||
|
||
Start message consumer before send message to the topic | ||
|
||
```php | ||
<?php | ||
/** @var \Enqueue\Wamp\WampContext $context */ | ||
|
||
$fooTopic = $context->createTopic('foo'); | ||
|
||
$consumer = $context->createConsumer($fooQueue); | ||
|
||
while (true) { | ||
if ($message = $consumer->receive()) { | ||
// process a message | ||
} | ||
} | ||
``` | ||
|
||
## Send message to topic | ||
|
||
```php | ||
<?php | ||
/** @var \Enqueue\Wamp\WampContext $context */ | ||
|
||
$fooTopic = $context->createTopic('foo'); | ||
$message = $context->createMessage('Hello world!'); | ||
|
||
$context->createProducer()->send($fooTopic, $message); | ||
``` | ||
|
||
[back to index](../index.md) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters