File tree Expand file tree Collapse file tree 2 files changed +18
-3
lines changed Expand file tree Collapse file tree 2 files changed +18
-3
lines changed Original file line number Diff line number Diff line change @@ -245,8 +245,11 @@ protected function getWebsocketConnections(): array
245245 */
246246 public function shouldPushToDescriptor (int $ fd ): bool
247247 {
248- return $ this ->server ->exist ($ fd )
249- && ($ this ->broadcast && $ this ->sender !== (int ) $ fd );
248+ if (! $ this ->server ->exist ($ fd )) {
249+ return false ;
250+ }
251+
252+ return $ this ->broadcast ? $ this ->sender !== (int ) $ fd : true ;
250253 }
251254
252255 /**
Original file line number Diff line number Diff line change @@ -115,7 +115,7 @@ public function testShouldPushToDescriptor()
115115 $ server = m::mock (Server::class);
116116 $ server ->shouldReceive ('exist ' )
117117 ->with ($ fd = 1 )
118- ->twice ( )
118+ ->times ( 3 )
119119 ->andReturn (true );
120120
121121 $ pusher = Pusher::make ([
@@ -141,5 +141,17 @@ public function testShouldPushToDescriptor()
141141 ], $ server );
142142
143143 $ this ->assertFalse ($ pusher ->shouldPushToDescriptor ($ fd ));
144+
145+ $ pusher = Pusher::make ([
146+ 'opcode ' => 1 ,
147+ 'sender ' => 1 ,
148+ 'fds ' => [],
149+ 'broadcast ' => false ,
150+ 'assigned ' => false ,
151+ 'event ' => 'event ' ,
152+ 'message ' => 'message '
153+ ], $ server );
154+
155+ $ this ->assertTrue ($ pusher ->shouldPushToDescriptor ($ fd ));
144156 }
145157}
You can’t perform that action at this time.
0 commit comments