mirror of
https://gitee.com/koogua/course-tencent-cloud.git
synced 2025-06-24 04:01:31 +08:00
1.websocket客户端主动发消息给服务端保持连接
2.群组用户只返回在线用户,减少传输量
This commit is contained in:
parent
23af401082
commit
1bf7449eed
@ -51,14 +51,18 @@ class Im extends Service
|
|||||||
|
|
||||||
$group = $validator->checkGroup($id);
|
$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 [];
|
return [];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$userRepo = new ImUserRepo();
|
||||||
|
|
||||||
|
$users = $userRepo->findByIds($userIds);
|
||||||
|
|
||||||
$baseUrl = kg_cos_url();
|
$baseUrl = kg_cos_url();
|
||||||
|
|
||||||
$result = [];
|
$result = [];
|
||||||
@ -211,7 +215,6 @@ class Im extends Service
|
|||||||
'name' => $user->name,
|
'name' => $user->name,
|
||||||
'avatar' => $user->avatar,
|
'avatar' => $user->avatar,
|
||||||
],
|
],
|
||||||
'status' => $user->status == 'online' ? 'online' : 'offline',
|
|
||||||
]);
|
]);
|
||||||
Gateway::sendToUid($friendUser->friend_id, $content);
|
Gateway::sendToUid($friendUser->friend_id, $content);
|
||||||
}
|
}
|
||||||
|
@ -71,10 +71,9 @@
|
|||||||
|
|
||||||
{% block include_js %}
|
{% block include_js %}
|
||||||
|
|
||||||
<script src="//imgcache.qq.com/open/qcloud/video/vcplayer/TcPlayer-2.3.2.js"></script>
|
{{ 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.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/chapter.action.js') }}
|
||||||
{{ js_include('desktop/js/course.share.js') }}
|
{{ js_include('desktop/js/course.share.js') }}
|
||||||
|
|
||||||
|
@ -56,8 +56,7 @@
|
|||||||
|
|
||||||
{% block include_js %}
|
{% block include_js %}
|
||||||
|
|
||||||
<script src="//imgcache.qq.com/open/qcloud/video/vcplayer/TcPlayer-2.3.3.js"></script>
|
{{ 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/course.share.js') }}
|
||||||
{{ js_include('desktop/js/chapter.action.js') }}
|
{{ js_include('desktop/js/chapter.action.js') }}
|
||||||
{{ js_include('desktop/js/chapter.vod.player.js') }}
|
{{ js_include('desktop/js/chapter.vod.player.js') }}
|
||||||
|
@ -4,7 +4,7 @@
|
|||||||
{% elseif gender == 2 %}
|
{% elseif gender == 2 %}
|
||||||
女
|
女
|
||||||
{% else %}
|
{% else %}
|
||||||
保密
|
密
|
||||||
{% endif %}
|
{% endif %}
|
||||||
{%- endmacro %}
|
{%- endmacro %}
|
||||||
|
|
||||||
|
@ -11,6 +11,9 @@ layui.use(['jquery', 'form', 'helper'], function () {
|
|||||||
|
|
||||||
socket.onopen = function () {
|
socket.onopen = function () {
|
||||||
console.log('socket connect success');
|
console.log('socket connect success');
|
||||||
|
setInterval(function () {
|
||||||
|
socket.send('ping');
|
||||||
|
}, 30000);
|
||||||
};
|
};
|
||||||
|
|
||||||
socket.onclose = function () {
|
socket.onclose = function () {
|
||||||
@ -24,9 +27,7 @@ layui.use(['jquery', 'form', 'helper'], function () {
|
|||||||
socket.onmessage = function (e) {
|
socket.onmessage = function (e) {
|
||||||
var data = JSON.parse(e.data);
|
var data = JSON.parse(e.data);
|
||||||
console.log(data);
|
console.log(data);
|
||||||
if (data.type === 'ping') {
|
if (data.type === 'bind_user') {
|
||||||
socket.send('pong...');
|
|
||||||
} else if (data.type === 'bind_user') {
|
|
||||||
bindUser(data.client_id);
|
bindUser(data.client_id);
|
||||||
} else if (data.type === 'new_message') {
|
} else if (data.type === 'new_message') {
|
||||||
showNewMessage(data);
|
showNewMessage(data);
|
@ -6,6 +6,9 @@ layui.use(['jquery', 'layim'], function () {
|
|||||||
|
|
||||||
socket.onopen = function () {
|
socket.onopen = function () {
|
||||||
console.log('socket connect success');
|
console.log('socket connect success');
|
||||||
|
setInterval(function () {
|
||||||
|
socket.send('ping');
|
||||||
|
}, 30000);
|
||||||
};
|
};
|
||||||
|
|
||||||
socket.onclose = function () {
|
socket.onclose = function () {
|
||||||
@ -19,9 +22,7 @@ layui.use(['jquery', 'layim'], function () {
|
|||||||
socket.onmessage = function (e) {
|
socket.onmessage = function (e) {
|
||||||
var data = JSON.parse(e.data);
|
var data = JSON.parse(e.data);
|
||||||
console.log(data);
|
console.log(data);
|
||||||
if (data.type === 'ping') {
|
if (data.type === 'bind_user') {
|
||||||
socket.send('pong...');
|
|
||||||
} else if (data.type === 'bind_user') {
|
|
||||||
bindUser(data);
|
bindUser(data);
|
||||||
refreshMessageBox();
|
refreshMessageBox();
|
||||||
} else if (data.type === 'new_group_user') {
|
} else if (data.type === 'new_group_user') {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user