From 1bf7449eed33677e7b0344bc98e2a21513eef7c0 Mon Sep 17 00:00:00 2001 From: xiaochong0302 Date: Wed, 9 Sep 2020 20:49:35 +0800 Subject: [PATCH] =?UTF-8?q?1.websocket=E5=AE=A2=E6=88=B7=E7=AB=AF=E4=B8=BB?= =?UTF-8?q?=E5=8A=A8=E5=8F=91=E6=B6=88=E6=81=AF=E7=BB=99=E6=9C=8D=E5=8A=A1?= =?UTF-8?q?=E7=AB=AF=E4=BF=9D=E6=8C=81=E8=BF=9E=E6=8E=A5=202.=E7=BE=A4?= =?UTF-8?q?=E7=BB=84=E7=94=A8=E6=88=B7=E5=8F=AA=E8=BF=94=E5=9B=9E=E5=9C=A8?= =?UTF-8?q?=E7=BA=BF=E7=94=A8=E6=88=B7=EF=BC=8C=E5=87=8F=E5=B0=91=E4=BC=A0?= =?UTF-8?q?=E8=BE=93=E9=87=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/Http/Desktop/Services/Im.php | 11 +++++++---- app/Http/Desktop/Views/chapter/live.volt | 5 ++--- app/Http/Desktop/Views/chapter/vod.volt | 3 +-- app/Http/Desktop/Views/search/user.volt | 2 +- .../js/{chapter.live.im.js => chapter.live.chat.js} | 7 ++++--- public/static/desktop/js/im.js | 7 ++++--- 6 files changed, 19 insertions(+), 16 deletions(-) rename public/static/desktop/js/{chapter.live.im.js => chapter.live.chat.js} (95%) diff --git a/app/Http/Desktop/Services/Im.php b/app/Http/Desktop/Services/Im.php index 3e848b1d..c5ebbe32 100644 --- a/app/Http/Desktop/Services/Im.php +++ b/app/Http/Desktop/Services/Im.php @@ -51,14 +51,18 @@ class Im extends Service $group = $validator->checkGroup($id); - $groupRepo = new ImGroupRepo(); + Gateway::$registerAddress = $this->getRegisterAddress(); - $users = $groupRepo->findUsers($group->id); + $userIds = Gateway::getUidListByGroup($this->getGroupName($group->id)); - if ($users->count() == 0) { + if (count($userIds) == 0) { return []; } + $userRepo = new ImUserRepo(); + + $users = $userRepo->findByIds($userIds); + $baseUrl = kg_cos_url(); $result = []; @@ -211,7 +215,6 @@ class Im extends Service 'name' => $user->name, 'avatar' => $user->avatar, ], - 'status' => $user->status == 'online' ? 'online' : 'offline', ]); Gateway::sendToUid($friendUser->friend_id, $content); } diff --git a/app/Http/Desktop/Views/chapter/live.volt b/app/Http/Desktop/Views/chapter/live.volt index 30403179..05831875 100644 --- a/app/Http/Desktop/Views/chapter/live.volt +++ b/app/Http/Desktop/Views/chapter/live.volt @@ -71,10 +71,9 @@ {% block include_js %} - - + {{ js_include('https://imgcache.qq.com/open/qcloud/video/vcplayer/TcPlayer-2.3.3.js', false) }} {{ js_include('desktop/js/chapter.live.player.js') }} - {{ js_include('desktop/js/chapter.live.im.js') }} + {{ js_include('desktop/js/chapter.live.chat.js') }} {{ js_include('desktop/js/chapter.action.js') }} {{ js_include('desktop/js/course.share.js') }} diff --git a/app/Http/Desktop/Views/chapter/vod.volt b/app/Http/Desktop/Views/chapter/vod.volt index d837c02f..706ef1a8 100644 --- a/app/Http/Desktop/Views/chapter/vod.volt +++ b/app/Http/Desktop/Views/chapter/vod.volt @@ -56,8 +56,7 @@ {% block include_js %} - - + {{ js_include('https://imgcache.qq.com/open/qcloud/video/vcplayer/TcPlayer-2.3.3.js', false) }} {{ js_include('desktop/js/course.share.js') }} {{ js_include('desktop/js/chapter.action.js') }} {{ js_include('desktop/js/chapter.vod.player.js') }} diff --git a/app/Http/Desktop/Views/search/user.volt b/app/Http/Desktop/Views/search/user.volt index 6de1ec3e..14b269de 100644 --- a/app/Http/Desktop/Views/search/user.volt +++ b/app/Http/Desktop/Views/search/user.volt @@ -4,7 +4,7 @@ {% elseif gender == 2 %} 女 {% else %} - 保密 + 密 {% endif %} {%- endmacro %} diff --git a/public/static/desktop/js/chapter.live.im.js b/public/static/desktop/js/chapter.live.chat.js similarity index 95% rename from public/static/desktop/js/chapter.live.im.js rename to public/static/desktop/js/chapter.live.chat.js index 834975cc..625dfc52 100644 --- a/public/static/desktop/js/chapter.live.im.js +++ b/public/static/desktop/js/chapter.live.chat.js @@ -11,6 +11,9 @@ layui.use(['jquery', 'form', 'helper'], function () { socket.onopen = function () { console.log('socket connect success'); + setInterval(function () { + socket.send('ping'); + }, 30000); }; socket.onclose = function () { @@ -24,9 +27,7 @@ layui.use(['jquery', 'form', 'helper'], function () { socket.onmessage = function (e) { var data = JSON.parse(e.data); console.log(data); - if (data.type === 'ping') { - socket.send('pong...'); - } else if (data.type === 'bind_user') { + if (data.type === 'bind_user') { bindUser(data.client_id); } else if (data.type === 'new_message') { showNewMessage(data); diff --git a/public/static/desktop/js/im.js b/public/static/desktop/js/im.js index 16cf1f06..dfafbd71 100644 --- a/public/static/desktop/js/im.js +++ b/public/static/desktop/js/im.js @@ -6,6 +6,9 @@ layui.use(['jquery', 'layim'], function () { socket.onopen = function () { console.log('socket connect success'); + setInterval(function () { + socket.send('ping'); + }, 30000); }; socket.onclose = function () { @@ -19,9 +22,7 @@ layui.use(['jquery', 'layim'], function () { socket.onmessage = function (e) { var data = JSON.parse(e.data); console.log(data); - if (data.type === 'ping') { - socket.send('pong...'); - } else if (data.type === 'bind_user') { + if (data.type === 'bind_user') { bindUser(data); refreshMessageBox(); } else if (data.type === 'new_group_user') {