Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 6 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,10 @@ Install Ably from the shell with:

$ composer require ably/ably-php --update-no-dev

Omit the `--update-no-dev` parameter, if you want to run tests. Then simply require composer's autoloader:
Then simply require composer's autoloader:

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

### Manual installation
Expand Down Expand Up @@ -111,6 +111,10 @@ $statsPage->next(); // retrieves the next page => \Ably\Models\PaginatedResult
$client->time(); // in milliseconds => 1430313364993
```

## Laravel

If you're using Laravel, you may want to check out [ably-php-laravel](https://packagist.org/packages/ably/ably-php-laravel) wrapper, which is a wrapper with Laravel-specific helper classes.

## Support, feedback and troubleshooting

Please visit http://support.ably.io/ for access to our knowledgebase and to ask for any assistance.
Expand Down
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
"require-dev": {
"phpunit/phpunit": ">=4.5"
},
"license": "MIT",
"license": "Apache-2.0",
"authors": [
{
"name": "Ably",
Expand Down
14 changes: 12 additions & 2 deletions src/Models/Message.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,24 @@ class Message extends BaseMessage {
* @var string|null The event name of the message.
*/
public $name;

/**
* @var string|null Connection key from a realtime connection,
* when publishing on behalf of it.
*/
public $connectionKey;

protected function encode() {
$msg = parent::encode();

if ( isset( $this->name ) && $this->name ) {
$msg->name = $this->name;
$msg->name = $this->name;
}

if ( isset( $this->connectionKey ) && $this->connectionKey ) {
$msg->connectionKey = $this->connectionKey;
}

return $msg;
}
}
}
17 changes: 17 additions & 0 deletions tests/ChannelMessagesTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -259,6 +259,23 @@ public function testTooLargeMessage() {
$channel->publish( $msg );
}

/**
* Verify that publishing on behalf of realtime clients works
*/
public function testPublishConnectionKey() {
$channel = self::$ably->channel( 'connKey' );


$msg = new Message();
$msg->name = 'delegatedMsg';
$msg->data = 'test payload';
$msg->connectionKey = 'fake!realtime_key';

// publishing the message with an invalid key must fail
$this->setExpectedException( 'Ably\Exceptions\AblyException', '', 40006 );
$channel->publish( $msg );
}

/**
* Encryption mismatch - publish message over encrypted channel, retrieve history over unencrypted channel
*/
Expand Down
1 change: 1 addition & 0 deletions tests/TypesTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ public function testMessageType() {
'id',
'clientId',
'connectionId',
'connectionKey',
'name',
'data',
'encoding',
Expand Down