Skip to content
This repository was archived by the owner on Mar 24, 2025. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
Prev Previous commit
fix shouldPushToDescriptor in pusher
  • Loading branch information
albertcht committed Mar 9, 2019
commit 4d28803a8c351e6d92c036dfa7f8eb123f4ea8a3
7 changes: 5 additions & 2 deletions src/Websocket/Pusher.php
Original file line number Diff line number Diff line change
Expand Up @@ -245,8 +245,11 @@ protected function getWebsocketConnections(): array
*/
public function shouldPushToDescriptor(int $fd): bool
{
return $this->server->exist($fd)
&& ($this->broadcast && $this->sender !== (int) $fd);
if (! $this->server->exist($fd)) {
return false;
}

return $this->broadcast ? $this->sender !== (int) $fd : true;
}

/**
Expand Down
14 changes: 13 additions & 1 deletion tests/Websocket/PusherTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ public function testShouldPushToDescriptor()
$server = m::mock(Server::class);
$server->shouldReceive('exist')
->with($fd = 1)
->twice()
->times(3)
->andReturn(true);

$pusher = Pusher::make([
Expand All @@ -141,5 +141,17 @@ public function testShouldPushToDescriptor()
], $server);

$this->assertFalse($pusher->shouldPushToDescriptor($fd));

$pusher = Pusher::make([
'opcode' => 1,
'sender' => 1,
'fds' => [],
'broadcast' => false,
'assigned' => false,
'event' => 'event',
'message' => 'message'
], $server);

$this->assertTrue($pusher->shouldPushToDescriptor($fd));
}
}