Pusher : -> .
This commit is contained in:
parent
929f1794ee
commit
87bf0ae05e
|
|
@ -14,7 +14,7 @@ class WebSocketException extends Exception
|
|||
public function getPayload()
|
||||
{
|
||||
return [
|
||||
'event' => 'pusher:error',
|
||||
'event' => 'pusher.error',
|
||||
'data' => [
|
||||
'message' => $this->getMessage(),
|
||||
'code' => $this->getCode(),
|
||||
|
|
|
|||
|
|
@ -36,7 +36,7 @@ class PusherChannelProtocolMessage extends PusherClientMessage
|
|||
$this->channelManager
|
||||
->connectionPonged($connection)
|
||||
->then(function () use ($connection) {
|
||||
$connection->send(json_encode(['event' => 'pusher:pong']));
|
||||
$connection->send(json_encode(['event' => 'pusher.pong']));
|
||||
|
||||
ConnectionPonged::dispatch($connection->app->id, $connection->socketId);
|
||||
});
|
||||
|
|
|
|||
|
|
@ -273,7 +273,7 @@ class WebSocketHandler implements MessageComponentInterface
|
|||
protected function establishConnection(ConnectionInterface $connection)
|
||||
{
|
||||
$connection->send(json_encode([
|
||||
'event' => 'pusher:connection_established',
|
||||
'event' => 'pusher.connection_established',
|
||||
'data' => json_encode([
|
||||
'socket_id' => $connection->socketId,
|
||||
'activity_timeout' => 30,
|
||||
|
|
|
|||
|
|
@ -258,6 +258,10 @@ class Controller
|
|||
{
|
||||
$event = explode('.', $message['event']);
|
||||
|
||||
if (strpos($event[0], 'pusher.') > -1) {
|
||||
$event = explode('.', $event[0]);
|
||||
}
|
||||
|
||||
if (strpos($event[0], 'pusher:') > -1) {
|
||||
$event = explode(':', $event[0]);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -321,7 +321,7 @@ class Handler implements MessageComponentInterface
|
|||
protected function establishConnection(ConnectionInterface $connection)
|
||||
{
|
||||
$connection->send(json_encode([
|
||||
'event' => 'pusher:connection_established',
|
||||
'event' => 'pusher.connection_established',
|
||||
'data' => json_encode([
|
||||
'socket_id' => $connection->socketId,
|
||||
'activity_timeout' => 30,
|
||||
|
|
|
|||
|
|
@ -11,7 +11,7 @@ class ConnectionTest extends TestCase
|
|||
$this->startServer();
|
||||
|
||||
$response = $this->await($this->joinWebSocketServer(['public-channel'], 'NonWorkingKey'));
|
||||
$this->assertSame('{"event":"pusher:error","data":{"message":"Could not find app key `NonWorkingKey`.","code":4001}}', (string) $response);
|
||||
$this->assertSame('{"event":"pusher.error","data":{"message":"Could not find app key `NonWorkingKey`.","code":4001}}', (string) $response);
|
||||
}
|
||||
|
||||
public function test_unconnected_app_cannot_store_statistics()
|
||||
|
|
@ -19,7 +19,7 @@ class ConnectionTest extends TestCase
|
|||
$this->startServer();
|
||||
|
||||
$response = $this->await($this->joinWebSocketServer(['public-channel'], 'NonWorkingKey'));
|
||||
$this->assertSame('{"event":"pusher:error","data":{"message":"Could not find app key `NonWorkingKey`.","code":4001}}', (string) $response);
|
||||
$this->assertSame('{"event":"pusher.error","data":{"message":"Could not find app key `NonWorkingKey`.","code":4001}}', (string) $response);
|
||||
|
||||
$count = $this->await($this->statisticsCollector->getStatistics());
|
||||
$this->assertCount(0, $count);
|
||||
|
|
@ -30,7 +30,7 @@ class ConnectionTest extends TestCase
|
|||
$this->startServer();
|
||||
|
||||
$response = $this->await($this->joinWebSocketServer(['public-channel'], 'TestOrigin'));
|
||||
$this->assertSame('{"event":"pusher:error","data":{"message":"The origin is not allowed for `TestOrigin`.","code":4009}}', (string) $response);
|
||||
$this->assertSame('{"event":"pusher.error","data":{"message":"The origin is not allowed for `TestOrigin`.","code":4009}}', (string) $response);
|
||||
}
|
||||
|
||||
public function test_origin_validation_should_fail_for_wrong_origin()
|
||||
|
|
@ -38,7 +38,7 @@ class ConnectionTest extends TestCase
|
|||
$this->startServer();
|
||||
|
||||
$response = $this->await($this->joinWebSocketServer(['public-channel'], 'TestOrigin', ['Origin' => 'https://google.ro']));
|
||||
$this->assertSame('{"event":"pusher:error","data":{"message":"The origin is not allowed for `TestOrigin`.","code":4009}}', (string) $response);
|
||||
$this->assertSame('{"event":"pusher.error","data":{"message":"The origin is not allowed for `TestOrigin`.","code":4009}}', (string) $response);
|
||||
}
|
||||
|
||||
public function test_origin_validation_should_pass_for_the_right_origin()
|
||||
|
|
@ -47,7 +47,7 @@ class ConnectionTest extends TestCase
|
|||
|
||||
$this->pusherServer->onOpen($connection);
|
||||
|
||||
$connection->assertSentEvent('pusher:connection_established');
|
||||
$connection->assertSentEvent('pusher.connection_established');
|
||||
}
|
||||
|
||||
public function test_close_connection()
|
||||
|
|
@ -87,7 +87,7 @@ class ConnectionTest extends TestCase
|
|||
|
||||
$this->pusherServer->onError($connection, new UnknownAppKey('NonWorkingKey'));
|
||||
|
||||
$connection->assertSentEvent('pusher:error', [
|
||||
$connection->assertSentEvent('pusher.error', [
|
||||
'data' => [
|
||||
'message' => 'Could not find app key `NonWorkingKey`.',
|
||||
'code' => 4001,
|
||||
|
|
@ -105,14 +105,14 @@ class ConnectionTest extends TestCase
|
|||
$failedConnection = $this->newActiveConnection(['test-channel']);
|
||||
|
||||
$failedConnection
|
||||
->assertSentEvent('pusher:error', ['data' => ['message' => 'Over capacity', 'code' => 4100]])
|
||||
->assertSentEvent('pusher.error', ['data' => ['message' => 'Over capacity', 'code' => 4100]])
|
||||
->assertClosed();
|
||||
}
|
||||
|
||||
public function test_close_all_new_connections_after_stating_the_server_does_not_accept_new_connections()
|
||||
{
|
||||
$this->newActiveConnection(['test-channel'])
|
||||
->assertSentEvent('pusher:connection_established')
|
||||
->assertSentEvent('pusher.connection_established')
|
||||
->assertSentEvent('pusher_internal:subscription_succeeded');
|
||||
|
||||
$this->channelManager->declineNewConnections();
|
||||
|
|
|
|||
|
|
@ -32,7 +32,7 @@ class AuthTest extends TestCase
|
|||
$this->pusherServer->onOpen($connection);
|
||||
|
||||
$message = new SignedMessage([
|
||||
'event' => 'pusher:subscribe',
|
||||
'event' => 'pusher.subscribe',
|
||||
'data' => [
|
||||
'channel' => 'private-channel',
|
||||
],
|
||||
|
|
@ -68,7 +68,7 @@ class AuthTest extends TestCase
|
|||
]);
|
||||
|
||||
$message = new SignedMessage([
|
||||
'event' => 'pusher:subscribe',
|
||||
'event' => 'pusher.subscribe',
|
||||
'data' => [
|
||||
'channel' => 'presence-channel',
|
||||
'channel_data' => $user,
|
||||
|
|
|
|||
|
|
@ -8,10 +8,10 @@ class PingTest extends TestCase
|
|||
{
|
||||
$connection = $this->newActiveConnection(['public-channel']);
|
||||
|
||||
$message = new Mocks\Message(['event' => 'pusher:ping']);
|
||||
$message = new Mocks\Message(['event' => 'pusher.ping']);
|
||||
|
||||
$this->pusherServer->onMessage($connection, $message);
|
||||
|
||||
$connection->assertSentEvent('pusher:pong');
|
||||
$connection->assertSentEvent('pusher.pong');
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -18,7 +18,7 @@ class PresenceChannelTest extends TestCase
|
|||
$connection = $this->newConnection();
|
||||
|
||||
$message = new Mocks\Message([
|
||||
'event' => 'pusher:subscribe',
|
||||
'event' => 'pusher.subscribe',
|
||||
'data' => [
|
||||
'auth' => 'invalid',
|
||||
'channel' => 'presence-channel',
|
||||
|
|
@ -45,7 +45,7 @@ class PresenceChannelTest extends TestCase
|
|||
$encodedUser = json_encode($user);
|
||||
|
||||
$message = new Mocks\SignedMessage([
|
||||
'event' => 'pusher:subscribe',
|
||||
'event' => 'pusher.subscribe',
|
||||
'data' => [
|
||||
'channel' => 'presence-channel',
|
||||
'channel_data' => $encodedUser,
|
||||
|
|
@ -173,7 +173,7 @@ class PresenceChannelTest extends TestCase
|
|||
});
|
||||
|
||||
$message = new Mocks\Message([
|
||||
'event' => 'pusher:unsubscribe',
|
||||
'event' => 'pusher.unsubscribe',
|
||||
'data' => [
|
||||
'channel' => 'presence-channel',
|
||||
],
|
||||
|
|
|
|||
|
|
@ -18,7 +18,7 @@ class PrivateChannelTest extends TestCase
|
|||
$connection = $this->newConnection();
|
||||
|
||||
$message = new Mocks\Message([
|
||||
'event' => 'pusher:subscribe',
|
||||
'event' => 'pusher.subscribe',
|
||||
'data' => [
|
||||
'auth' => 'invalid',
|
||||
'channel' => 'private-channel',
|
||||
|
|
@ -36,7 +36,7 @@ class PrivateChannelTest extends TestCase
|
|||
$this->pusherServer->onOpen($connection);
|
||||
|
||||
$message = new Mocks\SignedMessage([
|
||||
'event' => 'pusher:subscribe',
|
||||
'event' => 'pusher.subscribe',
|
||||
'data' => [
|
||||
'channel' => 'private-channel',
|
||||
],
|
||||
|
|
@ -66,7 +66,7 @@ class PrivateChannelTest extends TestCase
|
|||
});
|
||||
|
||||
$message = new Mocks\Message([
|
||||
'event' => 'pusher:unsubscribe',
|
||||
'event' => 'pusher.unsubscribe',
|
||||
'data' => [
|
||||
'channel' => 'private-channel',
|
||||
],
|
||||
|
|
|
|||
|
|
@ -21,7 +21,7 @@ class PublicChannelTest extends TestCase
|
|||
});
|
||||
|
||||
$connection->assertSentEvent(
|
||||
'pusher:connection_established',
|
||||
'pusher.connection_established',
|
||||
[
|
||||
'data' => json_encode([
|
||||
'socket_id' => $connection->socketId,
|
||||
|
|
@ -47,7 +47,7 @@ class PublicChannelTest extends TestCase
|
|||
});
|
||||
|
||||
$message = new Mocks\Message([
|
||||
'event' => 'pusher:unsubscribe',
|
||||
'event' => 'pusher.unsubscribe',
|
||||
'data' => [
|
||||
'channel' => 'public-channel',
|
||||
],
|
||||
|
|
|
|||
|
|
@ -427,7 +427,7 @@ abstract class TestCase extends Orchestra
|
|||
|
||||
foreach ($channelsToJoin as $channel) {
|
||||
$message = new Mocks\Message([
|
||||
'event' => 'pusher:subscribe',
|
||||
'event' => 'pusher.subscribe',
|
||||
'data' => [
|
||||
'channel' => $channel,
|
||||
],
|
||||
|
|
@ -462,7 +462,7 @@ abstract class TestCase extends Orchestra
|
|||
$encodedUser = json_encode($user);
|
||||
|
||||
$message = new Mocks\SignedMessage([
|
||||
'event' => 'pusher:subscribe',
|
||||
'event' => 'pusher.subscribe',
|
||||
'data' => [
|
||||
'channel' => $channel,
|
||||
'channel_data' => $encodedUser,
|
||||
|
|
@ -489,7 +489,7 @@ abstract class TestCase extends Orchestra
|
|||
$this->pusherServer->onOpen($connection);
|
||||
|
||||
$message = new Mocks\SignedMessage([
|
||||
'event' => 'pusher:subscribe',
|
||||
'event' => 'pusher.subscribe',
|
||||
'data' => [
|
||||
'channel' => $channel,
|
||||
],
|
||||
|
|
|
|||
Loading…
Reference in New Issue