Broadcast client messages to others only

This commit is contained in:
Marcel Pociot 2018-12-04 21:04:19 +01:00
parent 286629fd98
commit 3b2957facd
2 changed files with 7 additions and 4 deletions

View File

@ -42,6 +42,6 @@ class PusherClientMessage implements PusherMessage
$channel = $this->channelManager->find($this->connection->app->id, $this->payload->channel); $channel = $this->channelManager->find($this->connection->app->id, $this->payload->channel);
optional($channel)->broadcast($this->payload); optional($channel)->broadcastToOthers($this->connection, $this->payload);
} }
} }

View File

@ -39,7 +39,8 @@ class PusherClientMessageTest extends TestCase
], ],
]); ]);
$connection = $this->getConnectedWebSocketConnection(['test-channel']); $connection1 = $this->getConnectedWebSocketConnection(['test-channel']);
$connection2 = $this->getConnectedWebSocketConnection(['test-channel']);
$message = new Message(json_encode([ $message = new Message(json_encode([
'event' => 'client-test', 'event' => 'client-test',
@ -49,9 +50,11 @@ class PusherClientMessageTest extends TestCase
], ],
])); ]));
$this->pusherServer->onMessage($connection, $message); $this->pusherServer->onMessage($connection1, $message);
$connection->assertSentEvent('client-test', [ $connection1->assertNotSentEvent('client-test');
$connection2->assertSentEvent('client-test', [
'data' => [ 'data' => [
'client-event' => 'test' 'client-event' => 'test'
] ]