1 | <?php |
||
2 | |||
0 ignored issues
–
show
Coding Style
introduced
by
![]() |
|||
3 | namespace Hhxsv5\LaravelS\Swoole\Socket; |
||
4 | |||
5 | use Swoole\Http\Request; |
||
6 | use Swoole\Http\Response; |
||
7 | use Swoole\WebSocket\Frame; |
||
8 | use Swoole\WebSocket\Server; |
||
9 | |||
10 | interface WebSocketInterface |
||
0 ignored issues
–
show
|
|||
11 | { |
||
12 | /** |
||
13 | * The function is executed when a WebSocket connection is established and going into the handshake stage. |
||
14 | * The built-in default handshake protocol is Sec-WebSocket-Version: 13. You can override the default handshake protocol by implementing this function. |
||
15 | * After the onHandShake event is set, the onOpen event will not be triggered, and onOpen can be called manually |
||
16 | * This function is optional to create a WebSocket server. |
||
17 | * @see https://www.swoole.co.uk/docs/modules/swoole-websocket-server-on-handshake |
||
0 ignored issues
–
show
|
|||
18 | * @param Request $request |
||
0 ignored issues
–
show
|
|||
19 | * @param Response $response |
||
0 ignored issues
–
show
|
|||
20 | * @return void |
||
0 ignored issues
–
show
|
|||
21 | */ |
||
22 | // public function onHandShake(Request $request, Response $response); |
||
23 | |||
24 | /** |
||
25 | * The function is executed when a new WebSocket connection is established and passed the handshake stage. |
||
26 | * @see https://www.swoole.co.uk/docs/modules/swoole-websocket-server-on-open |
||
0 ignored issues
–
show
|
|||
27 | * @param Server $server |
||
0 ignored issues
–
show
|
|||
28 | * @param Request $request |
||
0 ignored issues
–
show
|
|||
29 | * @return void |
||
0 ignored issues
–
show
|
|||
30 | */ |
||
31 | public function onOpen(Server $server, Request $request); |
||
32 | |||
33 | /** |
||
34 | * The function is executed when a new data Frame is received by the WebSocket Server. The logics of processing the request from the WebSocket client should be defined within this function. |
||
35 | * @see https://www.swoole.co.uk/docs/modules/swoole-websocket-server-on-message |
||
0 ignored issues
–
show
|
|||
36 | * @param Server $server |
||
0 ignored issues
–
show
|
|||
37 | * @param Frame $frame |
||
0 ignored issues
–
show
|
|||
38 | * @return void |
||
0 ignored issues
–
show
|
|||
39 | */ |
||
40 | public function onMessage(Server $server, Frame $frame); |
||
41 | |||
42 | /** |
||
43 | * The function is executed when a new WebSocket connection is closed. |
||
44 | * @see https://www.swoole.co.uk/docs/modules/swoole-websocket-server-on-close |
||
0 ignored issues
–
show
|
|||
45 | * @param Server $server |
||
0 ignored issues
–
show
|
|||
46 | * @param $fd |
||
0 ignored issues
–
show
|
|||
47 | * @param $reactorId |
||
0 ignored issues
–
show
|
|||
48 | * @return void |
||
0 ignored issues
–
show
|
|||
49 | */ |
||
50 | public function onClose(Server $server, $fd, $reactorId); |
||
51 | } |