2727use function Hyperf \Engine \swoole_get_flags_from_frame ;
2828
2929/**
30- * @method void push(int $fd, $data, int $opcode = null, $finish = null)
31- * @method void disconnect(int $fd, int $code = null, string $reason = null)
30+ * @method bool push(int $fd, $data, int $opcode = null, $finish = null)
31+ * @method bool disconnect(int $fd, int $code = null, string $reason = null)
3232 */
3333class Sender
3434{
@@ -62,15 +62,22 @@ public function __call($name, $arguments)
6262 $ method = 'close ' ;
6363 }
6464
65- $ this ->responses [$ fd ]->{$ method }(...$ arguments );
66- $ this ->logger ->debug ("[WebSocket] Worker send to # {$ fd }" );
65+ $ result = $ this ->responses [$ fd ]->{$ method }(...$ arguments );
66+ $ this ->logger ->debug (
67+ sprintf (
68+ "[WebSocket] Worker send to # {$ fd }.Send %s " ,
69+ $ result ? 'success ' : 'failed '
70+ )
71+ );
72+ return $ result ;
6773 }
68- return ;
74+ return false ;
6975 }
7076
7177 if (! $ this ->proxy ($ fd , $ method , $ arguments )) {
7278 $ this ->sendPipeMessage ($ name , $ arguments );
7379 }
80+ return true ;
7481 }
7582
7683 public function pushFrame (int $ fd , FrameInterface $ frame ): bool
@@ -97,8 +104,13 @@ public function proxy(int $fd, string $method, array $arguments): bool
97104 if ($ result ) {
98105 /** @var \Swoole\WebSocket\Server $server */
99106 $ server = $ this ->getServer ();
100- $ server ->{$ method }(...$ arguments );
101- $ this ->logger ->debug ("[WebSocket] Worker. {$ this ->workerId } send to # {$ fd }" );
107+ $ result = $ server ->{$ method }(...$ arguments );
108+ $ this ->logger ->debug (
109+ sprintf (
110+ "[WebSocket] Worker. {$ this ->workerId } send to # {$ fd }.Send %s " ,
111+ $ result ? 'success ' : 'failed '
112+ )
113+ );
102114 }
103115
104116 return $ result ;
0 commit comments