From ccfe1727b666a4f67aabf7c3681583395ca21dd7 Mon Sep 17 00:00:00 2001 From: gzydong <837215079@qq.com> Date: Mon, 24 Jan 2022 22:32:33 +0800 Subject: [PATCH] =?UTF-8?q?feat:=E5=85=BC=E5=AE=B9=E5=BC=80=E5=8F=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/Controller/WebSocketController.php | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/app/Controller/WebSocketController.php b/app/Controller/WebSocketController.php index 22acf94..634ec28 100644 --- a/app/Controller/WebSocketController.php +++ b/app/Controller/WebSocketController.php @@ -54,6 +54,14 @@ class WebSocketController implements OnMessageInterface, OnOpenInterface, OnClos */ public function onOpen($server, Request $request): void { + $server->push($request->fd, json_encode([ + "event" => "connect", + "content" => [ + "ping_interval" => 20, + "ping_timeout" => 20 * 3, + ], + ])); + // 当前连接的用户 $user_id = auth('jwt')->user()->getId(); @@ -62,11 +70,6 @@ class WebSocketController implements OnMessageInterface, OnOpenInterface, OnClos // 判断是否存在异地登录 $isOnline = $this->client->isOnlineAll($user_id); - // 若开启单点登录,则主动关闭之前登录的连接 - if ($isOnline) { - // todo 预留 - } - // 绑定fd与用户关系 $this->client->bind($request->fd, $user_id);