Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
haishi
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
冷斌
haishi
Commits
39d7cbf2
Commit
39d7cbf2
authored
Apr 27, 2020
by
冷斌
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
update
parent
4333550e
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
117 additions
and
117 deletions
+117
-117
LiveNewIM/s1.js
+116
-116
api/Appapi/Model/Live.php
+1
-1
No files found.
LiveNewIM/s1.js
View file @
39d7cbf2
...
@@ -52,25 +52,25 @@ var io = socketio.listen(server,{
...
@@ -52,25 +52,25 @@ var io = socketio.listen(server,{
//setInterval(function(){
//setInterval(function(){
//global.gc();
//global.gc();
////console.log('GC done')
////console.log('GC done')
//}, 1000*30);
//}, 1000*30);
io
.
on
(
'connection'
,
function
(
socket
)
{
io
.
on
(
'connection'
,
function
(
socket
)
{
////console.log('连接成功');
////console.log('连接成功');
//numscount++;
//numscount++;
var
interval
;
var
interval
;
//进入房间
//进入房间
socket
.
on
(
'conn'
,
function
(
data
)
{
socket
.
on
(
'conn'
,
function
(
data
)
{
if
(
!
data
||
!
data
.
token
){
if
(
!
data
||
!
data
.
token
){
return
!
1
;
return
!
1
;
}
}
userid
=
data
.
uid
;
userid
=
data
.
uid
;
old_socket
=
sockets
[
userid
];
old_socket
=
sockets
[
userid
];
if
(
old_socket
&&
old_socket
!=
socket
)
{
if
(
old_socket
&&
old_socket
!=
socket
)
{
if
(
data
.
uid
==
data
.
roomnum
&&
data
.
stream
==
old_socket
.
stream
){
if
(
data
.
uid
==
data
.
roomnum
&&
data
.
stream
==
old_socket
.
stream
){
old_socket
.
reusing
=
1
;
old_socket
.
reusing
=
1
;
////console.log("重用");
////console.log("重用");
...
@@ -80,7 +80,7 @@ io.on('connection', function(socket) {
...
@@ -80,7 +80,7 @@ io.on('connection', function(socket) {
}
}
old_socket
.
disconnect
()
old_socket
.
disconnect
()
}
}
clientRedis
.
get
(
data
.
token
,
function
(
error
,
res
){
clientRedis
.
get
(
data
.
token
,
function
(
error
,
res
){
if
(
error
){
if
(
error
){
return
;
return
;
...
@@ -88,12 +88,12 @@ io.on('connection', function(socket) {
...
@@ -88,12 +88,12 @@ io.on('connection', function(socket) {
////console.log("[获取token失败]"+data.uid);
////console.log("[获取token失败]"+data.uid);
}
else
{
}
else
{
if
(
res
!=
null
){
if
(
res
!=
null
){
var
userInfo
=
evalJson
(
res
);
var
userInfo
=
evalJson
(
res
);
if
(
userInfo
[
'id'
]
==
data
.
uid
){
if
(
userInfo
[
'id'
]
==
data
.
uid
){
////console.log("[初始化验证成功]--"+data.uid+"---"+data.roomnum+'---'+data.stream);
////console.log("[初始化验证成功]--"+data.uid+"---"+data.roomnum+'---'+data.stream);
//获取验证token
//获取验证token
socket
.
token
=
data
.
token
;
socket
.
token
=
data
.
token
;
socket
.
roomnum
=
data
.
roomnum
;
socket
.
roomnum
=
data
.
roomnum
;
socket
.
stream
=
data
.
stream
;
socket
.
stream
=
data
.
stream
;
socket
.
nicename
=
userInfo
[
'user_nicename'
];
socket
.
nicename
=
userInfo
[
'user_nicename'
];
...
@@ -103,11 +103,11 @@ io.on('connection', function(socket) {
...
@@ -103,11 +103,11 @@ io.on('connection', function(socket) {
socket
.
usertype
=
parseInt
(
userInfo
[
'usertype'
]);
socket
.
usertype
=
parseInt
(
userInfo
[
'usertype'
]);
socket
.
uid
=
data
.
uid
;
socket
.
uid
=
data
.
uid
;
socket
.
reusing
=
0
;
socket
.
reusing
=
0
;
socket
.
join
(
data
.
roomnum
);
socket
.
join
(
data
.
roomnum
);
sockets
[
userid
]
=
socket
;
sockets
[
userid
]
=
socket
;
socket
.
emit
(
'conn'
,[
'ok'
]);
socket
.
emit
(
'conn'
,[
'ok'
]);
/* 重连时 处理PK */
/* 重连时 处理PK */
if
(
socket
.
roomnum
==
socket
.
uid
){
if
(
socket
.
roomnum
==
socket
.
uid
){
clientRedis
.
hget
(
'LiveConnect'
,
socket
.
uid
,
function
(
error
,
res
){
clientRedis
.
hget
(
'LiveConnect'
,
socket
.
uid
,
function
(
error
,
res
){
...
@@ -117,7 +117,7 @@ io.on('connection', function(socket) {
...
@@ -117,7 +117,7 @@ io.on('connection', function(socket) {
if
(
res
){
if
(
res
){
var
pkuid
=
res
;
var
pkuid
=
res
;
LiveConnect
[
socket
.
uid
]
=
pkuid
;
LiveConnect
[
socket
.
uid
]
=
pkuid
;
clientRedis
.
hget
(
'LivePK'
,
socket
.
uid
,
function
(
error
,
res
){
clientRedis
.
hget
(
'LivePK'
,
socket
.
uid
,
function
(
error
,
res
){
if
(
error
){
if
(
error
){
return
;
return
;
...
@@ -126,7 +126,7 @@ io.on('connection', function(socket) {
...
@@ -126,7 +126,7 @@ io.on('connection', function(socket) {
LivePK
[
socket
.
uid
]
=
pkuid
;
LivePK
[
socket
.
uid
]
=
pkuid
;
}
}
})
})
clientRedis
.
hget
(
'LivePK_gift'
,
socket
.
uid
,
function
(
error
,
res
){
clientRedis
.
hget
(
'LivePK_gift'
,
socket
.
uid
,
function
(
error
,
res
){
if
(
error
){
if
(
error
){
return
;
return
;
...
@@ -138,7 +138,7 @@ io.on('connection', function(socket) {
...
@@ -138,7 +138,7 @@ io.on('connection', function(socket) {
}
}
})
})
}
}
if
(
socket
.
roomnum
!=
socket
.
uid
&&
socket
.
uid
>
0
){
if
(
socket
.
roomnum
!=
socket
.
uid
&&
socket
.
uid
>
0
){
/* 处理有时 无座驾信息会崩溃的问题 */
/* 处理有时 无座驾信息会崩溃的问题 */
var
car_id
=
'0'
;
var
car_id
=
'0'
;
...
@@ -160,7 +160,7 @@ io.on('connection', function(socket) {
...
@@ -160,7 +160,7 @@ io.on('connection', function(socket) {
car_words
=
carinfo
[
'words'
];
car_words
=
carinfo
[
'words'
];
}
}
}
}
var
data_obj
=
{
var
data_obj
=
{
"msg"
:[
"msg"
:[
{
{
...
@@ -189,7 +189,7 @@ io.on('connection', function(socket) {
...
@@ -189,7 +189,7 @@ io.on('connection', function(socket) {
};
};
process_msg
(
io
,
socket
.
roomnum
,
JSON
.
stringify
(
data_obj
));
process_msg
(
io
,
socket
.
roomnum
,
JSON
.
stringify
(
data_obj
));
if
(
socket
.
stream
){
if
(
socket
.
stream
){
clientRedis
.
zadd
(
'user_'
+
socket
.
stream
,
socket
.
sign
,
userInfo
[
'id'
]);
clientRedis
.
zadd
(
'user_'
+
socket
.
stream
,
socket
.
sign
,
userInfo
[
'id'
]);
}
}
}
}
sendSystemMsg
(
socket
,
"直播内容包含任何低俗、暴露和涉黄内容,账号会被封禁;安全部门会24小时巡查哦~"
);
sendSystemMsg
(
socket
,
"直播内容包含任何低俗、暴露和涉黄内容,账号会被封禁;安全部门会24小时巡查哦~"
);
...
@@ -199,24 +199,24 @@ io.on('connection', function(socket) {
...
@@ -199,24 +199,24 @@ io.on('connection', function(socket) {
}
}
}
}
}
}
socket
.
emit
(
'conn'
,[
'no'
]);
socket
.
emit
(
'conn'
,[
'no'
]);
});
});
});
});
socket
.
on
(
'broadcast'
,
function
(
data
){
socket
.
on
(
'broadcast'
,
function
(
data
){
////console.log(data);
////console.log(data);
if
(
socket
.
token
!=
undefined
){
if
(
socket
.
token
!=
undefined
){
var
dataObj
=
typeof
data
==
'object'
?
data
:
evalJson
(
data
);
var
dataObj
=
typeof
data
==
'object'
?
data
:
evalJson
(
data
);
var
msg
=
dataObj
[
'msg'
][
0
];
var
msg
=
dataObj
[
'msg'
][
0
];
var
token
=
dataObj
[
'token'
];
var
token
=
dataObj
[
'token'
];
var
method
=
msg
[
'_method_'
];
var
method
=
msg
[
'_method_'
];
var
action
=
msg
[
'action'
];
var
action
=
msg
[
'action'
];
var
data_str
=
typeof
data
==
'object'
?
JSON
.
stringify
(
data
):
data
;
var
data_str
=
typeof
data
==
'object'
?
JSON
.
stringify
(
data
):
data
;
switch
(
method
){
switch
(
method
){
case
'SendMsg'
:{
//聊天
case
'SendMsg'
:{
//聊天
clientRedis
.
hget
(
"super"
,
socket
.
uid
,
function
(
error
,
res
){
clientRedis
.
hget
(
"super"
,
socket
.
uid
,
function
(
error
,
res
){
if
(
error
)
return
;
if
(
error
)
return
;
if
(
res
!=
null
){
if
(
res
!=
null
){
...
@@ -242,9 +242,9 @@ io.on('connection', function(socket) {
...
@@ -242,9 +242,9 @@ io.on('connection', function(socket) {
socket
.
emit
(
'broadcastingListen'
,[
JSON
.
stringify
(
newData
)]);
socket
.
emit
(
'broadcastingListen'
,[
JSON
.
stringify
(
newData
)]);
}
else
{
}
else
{
process_msg
(
io
,
socket
.
roomnum
,
data_str
);
process_msg
(
io
,
socket
.
roomnum
,
data_str
);
}
}
});
});
}
}
});
});
break
;
break
;
}
}
...
@@ -265,24 +265,24 @@ io.on('connection', function(socket) {
...
@@ -265,24 +265,24 @@ io.on('connection', function(socket) {
var
total
=
Number
(
resObj
.
totalcoin
);
var
total
=
Number
(
resObj
.
totalcoin
);
LivePK_gift
[
socket
.
roomnum
]
+=
total
;
LivePK_gift
[
socket
.
roomnum
]
+=
total
;
clientRedis
.
hincrby
(
'LivePK_gift'
,
socket
.
roomnum
,
total
);
clientRedis
.
hincrby
(
'LivePK_gift'
,
socket
.
roomnum
,
total
);
pkuid1
=
''
+
socket
.
roomnum
;
pkuid1
=
''
+
socket
.
roomnum
;
pkuid2
=
''
+
pkuid
;
pkuid2
=
''
+
pkuid
;
pktotal1
=
''
+
LivePK_gift
[
socket
.
roomnum
];
pktotal1
=
''
+
LivePK_gift
[
socket
.
roomnum
];
pktotal2
=
''
+
LivePK_gift
[
pkuid
];
pktotal2
=
''
+
LivePK_gift
[
pkuid
];
}
}
dataObj
[
'msg'
][
0
][
'ifpk'
]
=
ifpk
;
dataObj
[
'msg'
][
0
][
'ifpk'
]
=
ifpk
;
dataObj
[
'msg'
][
0
][
'pkuid1'
]
=
pkuid1
;
dataObj
[
'msg'
][
0
][
'pkuid1'
]
=
pkuid1
;
dataObj
[
'msg'
][
0
][
'pkuid2'
]
=
pkuid2
;
dataObj
[
'msg'
][
0
][
'pkuid2'
]
=
pkuid2
;
dataObj
[
'msg'
][
0
][
'pktotal1'
]
=
pktotal1
;
dataObj
[
'msg'
][
0
][
'pktotal1'
]
=
pktotal1
;
dataObj
[
'msg'
][
0
][
'pktotal2'
]
=
pktotal2
;
dataObj
[
'msg'
][
0
][
'pktotal2'
]
=
pktotal2
;
io
.
sockets
.
in
(
socket
.
roomnum
).
emit
(
'broadcastingListen'
,[
JSON
.
stringify
(
dataObj
)]);
io
.
sockets
.
in
(
socket
.
roomnum
).
emit
(
'broadcastingListen'
,[
JSON
.
stringify
(
dataObj
)]);
if
(
pkuid
>
0
){
if
(
pkuid
>
0
){
io
.
sockets
.
in
(
pkuid
).
emit
(
'broadcastingListen'
,[
JSON
.
stringify
(
dataObj
)]);
io
.
sockets
.
in
(
pkuid
).
emit
(
'broadcastingListen'
,[
JSON
.
stringify
(
dataObj
)]);
}
}
/* 幸运中奖 */
/* 幸运中奖 */
if
(
resObj
.
isluck
==
1
&&
resObj
.
isluckall
==
1
){
if
(
resObj
.
isluck
==
1
&&
resObj
.
isluckall
==
1
){
var
data_luck
=
{
var
data_luck
=
{
...
@@ -305,7 +305,7 @@ io.on('connection', function(socket) {
...
@@ -305,7 +305,7 @@ io.on('connection', function(socket) {
io
.
emit
(
'broadcastingListen'
,[
JSON
.
stringify
(
data_luck
)]);
io
.
emit
(
'broadcastingListen'
,[
JSON
.
stringify
(
data_luck
)]);
}
}
/* 幸运中奖 */
/* 幸运中奖 */
/* 奖池升级 */
/* 奖池升级 */
if
(
resObj
.
isup
==
1
){
if
(
resObj
.
isup
==
1
){
var
data_up
=
{
var
data_up
=
{
...
@@ -323,7 +323,7 @@ io.on('connection', function(socket) {
...
@@ -323,7 +323,7 @@ io.on('connection', function(socket) {
io
.
emit
(
'broadcastingListen'
,[
JSON
.
stringify
(
data_up
)]);
io
.
emit
(
'broadcastingListen'
,[
JSON
.
stringify
(
data_up
)]);
}
}
/* 奖池升级 */
/* 奖池升级 */
/* 奖池中奖 */
/* 奖池中奖 */
if
(
resObj
.
iswin
==
1
){
if
(
resObj
.
iswin
==
1
){
var
data_win
=
{
var
data_win
=
{
...
@@ -342,7 +342,7 @@ io.on('connection', function(socket) {
...
@@ -342,7 +342,7 @@ io.on('connection', function(socket) {
"retmsg"
:
"OK"
"retmsg"
:
"OK"
};
};
io
.
emit
(
'broadcastingListen'
,[
JSON
.
stringify
(
data_win
)]);
io
.
emit
(
'broadcastingListen'
,[
JSON
.
stringify
(
data_win
)]);
var
data_up
=
{
var
data_up
=
{
"msg"
:[
"msg"
:[
{
{
...
@@ -358,7 +358,7 @@ io.on('connection', function(socket) {
...
@@ -358,7 +358,7 @@ io.on('connection', function(socket) {
io
.
emit
(
'broadcastingListen'
,[
JSON
.
stringify
(
data_up
)]);
io
.
emit
(
'broadcastingListen'
,[
JSON
.
stringify
(
data_up
)]);
}
}
/* 奖池中奖 */
/* 奖池中奖 */
clientRedis
.
del
(
gifToken
);
clientRedis
.
del
(
gifToken
);
}
}
});
});
...
@@ -373,7 +373,7 @@ io.on('connection', function(socket) {
...
@@ -373,7 +373,7 @@ io.on('connection', function(socket) {
var
data_str
=
JSON
.
stringify
(
dataObj
);
var
data_str
=
JSON
.
stringify
(
dataObj
);
process_msg
(
io
,
socket
.
roomnum
,
data_str
);
process_msg
(
io
,
socket
.
roomnum
,
data_str
);
clientRedis
.
del
(
barragetoken
);
clientRedis
.
del
(
barragetoken
);
}
}
});
});
break
;
break
;
}
}
...
@@ -388,12 +388,12 @@ io.on('connection', function(socket) {
...
@@ -388,12 +388,12 @@ io.on('connection', function(socket) {
return
!
1
;
return
!
1
;
}
}
var
res_j
=
JSON
.
parse
(
res
);
var
res_j
=
JSON
.
parse
(
res
);
if
(
socket
.
uid
==
res_j
[
'uid'
]
||
socket
.
uid
==
socket
.
roomnum
){
if
(
socket
.
uid
==
res_j
[
'uid'
]
||
socket
.
uid
==
socket
.
roomnum
){
clientRedis
.
hdel
(
'ShowVideo'
,
socket
.
roomnum
);
clientRedis
.
hdel
(
'ShowVideo'
,
socket
.
roomnum
);
process_msg
(
io
,
socket
.
roomnum
,
data_str
);
process_msg
(
io
,
socket
.
roomnum
,
data_str
);
}
}
});
});
}
else
{
}
else
{
process_msg
(
io
,
socket
.
roomnum
,
data_str
);
process_msg
(
io
,
socket
.
roomnum
,
data_str
);
}
}
...
@@ -429,8 +429,8 @@ io.on('connection', function(socket) {
...
@@ -429,8 +429,8 @@ io.on('connection', function(socket) {
clientRedis
.
hget
(
"super"
,
socket
.
uid
,
function
(
error
,
res
){
clientRedis
.
hget
(
"super"
,
socket
.
uid
,
function
(
error
,
res
){
if
(
error
)
return
;
if
(
error
)
return
;
if
(
res
!=
null
){
if
(
res
!=
null
){
process_msg
(
io
,
socket
.
roomnum
,
'stopplay'
);
process_msg
(
io
,
socket
.
roomnum
,
'stopplay'
);
}
}
});
});
break
;
break
;
}
}
...
@@ -439,13 +439,13 @@ io.on('connection', function(socket) {
...
@@ -439,13 +439,13 @@ io.on('connection', function(socket) {
process_msg
(
io
,
socket
.
roomnum
,
data_str
);
process_msg
(
io
,
socket
.
roomnum
,
data_str
);
}
}
break
;
break
;
}
}
case
'setAdmin'
:{
//设置/取消管理员
case
'setAdmin'
:{
//设置/取消管理员
if
(
socket
.
usertype
==
50
){
if
(
socket
.
usertype
==
50
){
process_msg
(
io
,
socket
.
roomnum
,
data_str
);
process_msg
(
io
,
socket
.
roomnum
,
data_str
);
}
}
break
;
break
;
}
}
case
'StartEndLive'
:{
case
'StartEndLive'
:{
if
(
socket
.
usertype
==
50
){
if
(
socket
.
usertype
==
50
){
socket
.
broadcast
.
to
(
socket
.
roomnum
).
emit
(
'broadcastingListen'
,[
data_str
]);
socket
.
broadcast
.
to
(
socket
.
roomnum
).
emit
(
'broadcastingListen'
,[
data_str
]);
...
@@ -493,23 +493,23 @@ io.on('connection', function(socket) {
...
@@ -493,23 +493,23 @@ io.on('connection', function(socket) {
LiveConnect_pull
[
socket
.
uid
]
=
pkpull
;
LiveConnect_pull
[
socket
.
uid
]
=
pkpull
;
//console.log('LiveConnect_pull--'+socket.uid+'-----'+pkpull);
//console.log('LiveConnect_pull--'+socket.uid+'-----'+pkpull);
clientRedis
.
hset
(
'LiveConnect_pull'
,
socket
.
uid
,
pkpull
);
clientRedis
.
hset
(
'LiveConnect_pull'
,
socket
.
uid
,
pkpull
);
/* 更新 连麦关系 */
/* 更新 连麦关系 */
LiveConnect
[
socket
.
uid
]
=
pkuid
;
LiveConnect
[
socket
.
uid
]
=
pkuid
;
LiveConnect
[
pkuid
]
=
socket
.
uid
;
LiveConnect
[
pkuid
]
=
socket
.
uid
;
//console.log('LiveConnect');
//console.log('LiveConnect');
//console.log(socket.uid)
//console.log(socket.uid)
//console.log(pkuid);
//console.log(pkuid);
clientRedis
.
hset
(
'LiveConnect'
,
socket
.
uid
,
pkuid
);
clientRedis
.
hset
(
'LiveConnect'
,
socket
.
uid
,
pkuid
);
clientRedis
.
hset
(
'LiveConnect'
,
pkuid
,
socket
.
uid
);
clientRedis
.
hset
(
'LiveConnect'
,
pkuid
,
socket
.
uid
);
/* 更新数据库 */
/* 更新数据库 */
var
sign_data
=
{
uid
:
socket
.
uid
,
pkuid
:
pkuid
,
type
:
1
};
var
sign_data
=
{
uid
:
socket
.
uid
,
pkuid
:
pkuid
,
type
:
1
};
var
sign
=
setSign
(
sign_data
);
var
sign
=
setSign
(
sign_data
);
request
(
config
[
'WEBADDRESS'
]
+
"?service=Livepk.changeLive&uid="
+
socket
.
uid
+
"&pkuid="
+
pkuid
+
"&type=1&sign="
+
sign
,
function
(
error
,
response
,
body
){});
request
(
config
[
'WEBADDRESS'
]
+
"?service=Livepk.changeLive&uid="
+
socket
.
uid
+
"&pkuid="
+
pkuid
+
"&type=1&sign="
+
sign
,
function
(
error
,
response
,
body
){});
/* 发送连麦成功信息 */
/* 发送连麦成功信息 */
/* 当前房间 */
/* 当前房间 */
var
data_obj
=
{
var
data_obj
=
{
...
@@ -527,7 +527,7 @@ io.on('connection', function(socket) {
...
@@ -527,7 +527,7 @@ io.on('connection', function(socket) {
"retcode"
:
"000000"
,
"retcode"
:
"000000"
,
"retmsg"
:
"OK"
"retmsg"
:
"OK"
};
};
process_msg
(
io
,
socket
.
roomnum
,
JSON
.
stringify
(
data_obj
));
process_msg
(
io
,
socket
.
roomnum
,
JSON
.
stringify
(
data_obj
));
/* 对方房间 */
/* 对方房间 */
var
data_obj_pk
=
{
var
data_obj_pk
=
{
...
@@ -546,7 +546,7 @@ io.on('connection', function(socket) {
...
@@ -546,7 +546,7 @@ io.on('connection', function(socket) {
"retmsg"
:
"OK"
"retmsg"
:
"OK"
};
};
process_msg
(
io
,
pkuid
,
JSON
.
stringify
(
data_obj_pk
));
process_msg
(
io
,
pkuid
,
JSON
.
stringify
(
data_obj_pk
));
}
else
if
(
action
==
'5'
){
}
else
if
(
action
==
'5'
){
/* 清除连麦信息 */
/* 清除连麦信息 */
endLiveConnect
(
io
,
socket
.
uid
);
endLiveConnect
(
io
,
socket
.
uid
);
...
@@ -555,7 +555,7 @@ io.on('connection', function(socket) {
...
@@ -555,7 +555,7 @@ io.on('connection', function(socket) {
if
(
socket_pkuid
){
if
(
socket_pkuid
){
socket_pkuid
.
emit
(
'broadcastingListen'
,[
data_str
]);
socket_pkuid
.
emit
(
'broadcastingListen'
,[
data_str
]);
}
}
}
}
break
;
break
;
}
}
...
@@ -571,17 +571,17 @@ io.on('connection', function(socket) {
...
@@ -571,17 +571,17 @@ io.on('connection', function(socket) {
/* 更新PK状态 */
/* 更新PK状态 */
LivePK
[
socket
.
uid
]
=
pkuid
;
LivePK
[
socket
.
uid
]
=
pkuid
;
LivePK
[
pkuid
]
=
socket
.
uid
;
LivePK
[
pkuid
]
=
socket
.
uid
;
LivePK_gift
[
socket
.
uid
]
=
0
;
LivePK_gift
[
socket
.
uid
]
=
0
;
LivePK_gift
[
pkuid
]
=
0
;
LivePK_gift
[
pkuid
]
=
0
;
//console.log('LivePK');
//console.log('LivePK');
//console.log(socket.uid);
//console.log(socket.uid);
//console.log(pkuid);
//console.log(pkuid);
clientRedis
.
hset
(
'LivePK'
,
socket
.
uid
,
pkuid
);
clientRedis
.
hset
(
'LivePK'
,
socket
.
uid
,
pkuid
);
clientRedis
.
hset
(
'LivePK'
,
pkuid
,
socket
.
uid
);
clientRedis
.
hset
(
'LivePK'
,
pkuid
,
socket
.
uid
);
clientRedis
.
hset
(
'LivePK_gift'
,
socket
.
uid
,
0
);
clientRedis
.
hset
(
'LivePK_gift'
,
socket
.
uid
,
0
);
clientRedis
.
hset
(
'LivePK_gift'
,
pkuid
,
0
);
clientRedis
.
hset
(
'LivePK_gift'
,
pkuid
,
0
);
...
@@ -601,7 +601,7 @@ io.on('connection', function(socket) {
...
@@ -601,7 +601,7 @@ io.on('connection', function(socket) {
"retcode"
:
"000000"
,
"retcode"
:
"000000"
,
"retmsg"
:
"OK"
"retmsg"
:
"OK"
};
};
process_msg
(
io
,
socket
.
roomnum
,
JSON
.
stringify
(
data_obj
));
process_msg
(
io
,
socket
.
roomnum
,
JSON
.
stringify
(
data_obj
));
/* 对方房间 */
/* 对方房间 */
var
data_obj_pk
=
{
var
data_obj_pk
=
{
...
@@ -619,22 +619,22 @@ io.on('connection', function(socket) {
...
@@ -619,22 +619,22 @@ io.on('connection', function(socket) {
"retmsg"
:
"OK"
"retmsg"
:
"OK"
};
};
process_msg
(
io
,
pkuid
,
JSON
.
stringify
(
data_obj_pk
));
process_msg
(
io
,
pkuid
,
JSON
.
stringify
(
data_obj_pk
));
clearTimeout
(
LivePK_timer
[
socket
.
uid
]);
clearTimeout
(
LivePK_timer
[
socket
.
uid
]);
LivePK_timer
[
socket
.
uid
]
=
null
;
LivePK_timer
[
socket
.
uid
]
=
null
;
var
time
=
Math
.
floor
(
(
new
Date
()).
getTime
()
/
1000
);
var
time
=
Math
.
floor
(
(
new
Date
()).
getTime
()
/
1000
);
//console.log('LivePK_timer_'+socket.uid+'___'+pkuid);
//console.log('LivePK_timer_'+socket.uid+'___'+pkuid);
//console.log('LivePK_timer');
//console.log('LivePK_timer');
//console.log(time);
//console.log(time);
clientRedis
.
hset
(
'LivePK_timer'
,
socket
.
uid
,
time
);
clientRedis
.
hset
(
'LivePK_timer'
,
socket
.
uid
,
time
);
LivePK_timer
[
socket
.
uid
]
=
setTimeout
(
function
()
{
//定时发送结果
LivePK_timer
[
socket
.
uid
]
=
setTimeout
(
function
()
{
//定时发送结果
endLivePk
(
io
,
socket
.
uid
,
0
);
endLivePk
(
io
,
socket
.
uid
,
0
);
},
5
*
60
*
1000
);
},
7
*
60
*
1000
);
//5*60*1000
//5*60*1000
}
else
if
(
action
==
'5'
){
}
else
if
(
action
==
'5'
){
/* 清除PK信息 */
/* 清除PK信息 */
endLivePk
(
io
,
socket
.
uid
,
1
);
endLivePk
(
io
,
socket
.
uid
,
1
);
...
@@ -690,7 +690,7 @@ io.on('connection', function(socket) {
...
@@ -690,7 +690,7 @@ io.on('connection', function(socket) {
if
(
error
)
return
;
if
(
error
)
return
;
////console.log(body);
////console.log(body);
var
res
=
evalJson
(
body
);
var
res
=
evalJson
(
body
);
if
(
response
.
statusCode
==
200
&&
res
.
data
.
code
==
0
){
if
(
response
.
statusCode
==
200
&&
res
.
data
.
code
==
0
){
var
resObj
=
res
.
data
.
info
;
var
resObj
=
res
.
data
.
info
;
dataObj
[
'msg'
][
0
][
'ct'
]
=
resObj
;
dataObj
[
'msg'
][
0
][
'ct'
]
=
resObj
;
...
@@ -738,7 +738,7 @@ io.on('connection', function(socket) {
...
@@ -738,7 +738,7 @@ io.on('connection', function(socket) {
request
(
config
[
'WEBADDRESS'
]
+
"?service=Game.endGame&liveuid="
+
socket
.
uid
+
"&token="
+
socket
.
token
+
"&gameid="
+
gameid
+
"&type=1"
,
function
(
error
,
response
,
body
){
request
(
config
[
'WEBADDRESS'
]
+
"?service=Game.endGame&liveuid="
+
socket
.
uid
+
"&token="
+
socket
.
token
+
"&gameid="
+
gameid
+
"&type=1"
,
function
(
error
,
response
,
body
){
if
(
error
)
return
;
if
(
error
)
return
;
var
res
=
evalJson
(
body
);
var
res
=
evalJson
(
body
);
if
(
response
.
statusCode
==
200
&&
res
.
data
.
code
==
0
){
if
(
response
.
statusCode
==
200
&&
res
.
data
.
code
==
0
){
var
resObj
=
res
.
data
.
info
;
var
resObj
=
res
.
data
.
info
;
dataObj
[
'msg'
][
0
][
'ct'
]
=
resObj
;
dataObj
[
'msg'
][
0
][
'ct'
]
=
resObj
;
...
@@ -786,12 +786,12 @@ io.on('connection', function(socket) {
...
@@ -786,12 +786,12 @@ io.on('connection', function(socket) {
});
});
}
}
}
}
}
}
});
});
socket
.
on
(
'superadminaction'
,
function
(
data
){
socket
.
on
(
'superadminaction'
,
function
(
data
){
if
(
data
[
'token'
]
==
config
[
'TOKEN'
]){
if
(
data
[
'token'
]
==
config
[
'TOKEN'
]){
io
.
sockets
.
in
(
data
[
'roomnum'
]).
emit
(
"broadcastingListen"
,
[
'stopplay'
]);
io
.
sockets
.
in
(
data
[
'roomnum'
]).
emit
(
"broadcastingListen"
,
[
'stopplay'
]);
...
@@ -815,18 +815,18 @@ io.on('connection', function(socket) {
...
@@ -815,18 +815,18 @@ io.on('connection', function(socket) {
io
.
emit
(
'broadcastingListen'
,[
JSON
.
stringify
(
data_obj
)]);
io
.
emit
(
'broadcastingListen'
,[
JSON
.
stringify
(
data_obj
)]);
}
}
});
});
//资源释放
//资源释放
socket
.
on
(
'disconnect'
,
function
()
{
socket
.
on
(
'disconnect'
,
function
()
{
/* numscount--;
/* numscount--;
if(numscount<0){
if(numscount<0){
numscount=0;
numscount=0;
} */
} */
if
(
socket
.
roomnum
==
null
||
socket
.
token
==
null
||
socket
.
uid
<=
0
){
if
(
socket
.
roomnum
==
null
||
socket
.
token
==
null
||
socket
.
uid
<=
0
){
return
!
1
;
return
!
1
;
}
}
d
.
run
(
function
()
{
d
.
run
(
function
()
{
/* 用户连麦 */
/* 用户连麦 */
clientRedis
.
hget
(
'ShowVideo'
,
socket
.
roomnum
,
function
(
error
,
res
){
clientRedis
.
hget
(
'ShowVideo'
,
socket
.
roomnum
,
function
(
error
,
res
){
...
@@ -837,7 +837,7 @@ io.on('connection', function(socket) {
...
@@ -837,7 +837,7 @@ io.on('connection', function(socket) {
return
!
1
;
return
!
1
;
}
}
var
res_j
=
JSON
.
parse
(
res
);
var
res_j
=
JSON
.
parse
(
res
);
if
(
socket
.
uid
==
res_j
[
'uid'
]
||
socket
.
uid
==
socket
.
roomnum
){
if
(
socket
.
uid
==
res_j
[
'uid'
]
||
socket
.
uid
==
socket
.
roomnum
){
clientRedis
.
hdel
(
'ShowVideo'
,
socket
.
roomnum
);
clientRedis
.
hdel
(
'ShowVideo'
,
socket
.
roomnum
);
var
data_obj
=
{
var
data_obj
=
{
...
@@ -853,22 +853,22 @@ io.on('connection', function(socket) {
...
@@ -853,22 +853,22 @@ io.on('connection', function(socket) {
"retcode"
:
"000000"
,
"retcode"
:
"000000"
,
"retmsg"
:
"OK"
"retmsg"
:
"OK"
};
};
process_msg
(
io
,
socket
.
roomnum
,
JSON
.
stringify
(
data_obj
));
process_msg
(
io
,
socket
.
roomnum
,
JSON
.
stringify
(
data_obj
));
}
}
});
});
if
(
socket
.
roomnum
==
socket
.
uid
){
if
(
socket
.
roomnum
==
socket
.
uid
){
/* 主播 */
/* 主播 */
if
(
socket
.
reusing
==
0
){
if
(
socket
.
reusing
==
0
){
request
(
config
[
'WEBADDRESS'
]
+
"?service=Live.stopRoom&uid="
+
socket
.
uid
+
"&token="
+
socket
.
token
+
"&type=1&stream="
+
socket
.
stream
,
function
(
error
,
response
,
body
){
request
(
config
[
'WEBADDRESS'
]
+
"?service=Live.stopRoom&uid="
+
socket
.
uid
+
"&token="
+
socket
.
token
+
"&type=1&stream="
+
socket
.
stream
,
function
(
error
,
response
,
body
){
console
.
log
(
body
);
console
.
log
(
body
);
});
});
var
data_obj
=
{
var
data_obj
=
{
"retmsg"
:
"ok"
,
"retmsg"
:
"ok"
,
"retcode"
:
"000000"
,
"retcode"
:
"000000"
,
...
@@ -885,9 +885,9 @@ io.on('connection', function(socket) {
...
@@ -885,9 +885,9 @@ io.on('connection', function(socket) {
endLiveConnect
(
io
,
socket
.
uid
);
endLiveConnect
(
io
,
socket
.
uid
);
}
}
}
else
{
}
else
{
/* 观众 */
/* 观众 */
clientRedis
.
zrem
(
'user_'
+
socket
.
stream
,
socket
.
uid
,
function
(
error
,
res
){
clientRedis
.
zrem
(
'user_'
+
socket
.
stream
,
socket
.
uid
,
function
(
error
,
res
){
...
@@ -912,14 +912,14 @@ io.on('connection', function(socket) {
...
@@ -912,14 +912,14 @@ io.on('connection', function(socket) {
"retcode"
:
"000000"
,
"retcode"
:
"000000"
,
"retmsg"
:
"OK"
"retmsg"
:
"OK"
};
};
process_msg
(
io
,
socket
.
roomnum
,
JSON
.
stringify
(
data_obj
));
process_msg
(
io
,
socket
.
roomnum
,
JSON
.
stringify
(
data_obj
));
}
}
});
});
}
}
////console.log(socket.roomnum+"==="+socket.token+"===="+socket.uid+"======"+socket.stream);
////console.log(socket.roomnum+"==="+socket.token+"===="+socket.uid+"======"+socket.stream);
socket
.
leave
(
socket
.
roomnum
);
socket
.
leave
(
socket
.
roomnum
);
delete
io
.
sockets
.
sockets
[
socket
.
id
];
delete
io
.
sockets
.
sockets
[
socket
.
id
];
sockets
[
socket
.
uid
]
=
null
;
sockets
[
socket
.
uid
]
=
null
;
...
@@ -945,7 +945,7 @@ function sendSystemMsg(socket,msg){
...
@@ -945,7 +945,7 @@ function sendSystemMsg(socket,msg){
"retmsg"
:
"OK"
"retmsg"
:
"OK"
};
};
socket
.
emit
(
'broadcastingListen'
,[
JSON
.
stringify
(
data_obj
)]);
socket
.
emit
(
'broadcastingListen'
,[
JSON
.
stringify
(
data_obj
)]);
}
}
function
evalJson
(
data
){
function
evalJson
(
data
){
return
eval
(
"("
+
data
+
")"
);
return
eval
(
"("
+
data
+
")"
);
...
@@ -973,50 +973,50 @@ function send_msg(io,roomnum){
...
@@ -973,50 +973,50 @@ function send_msg(io,roomnum){
/* 主播连麦结束处理 */
/* 主播连麦结束处理 */
function
endLiveConnect
(
io
,
uid
){
function
endLiveConnect
(
io
,
uid
){
if
(
LivePK_timer
[
uid
]){
if
(
LivePK_timer
[
uid
]){
clearTimeout
(
LivePK_timer
[
uid
]);
clearTimeout
(
LivePK_timer
[
uid
]);
LivePK_timer
[
uid
]
=
null
;
LivePK_timer
[
uid
]
=
null
;
}
}
var
pkuid
=
LiveConnect
[
uid
];
var
pkuid
=
LiveConnect
[
uid
];
if
(
!
pkuid
||
pkuid
<=
0
){
if
(
!
pkuid
||
pkuid
<=
0
){
pkuid
=
0
;
pkuid
=
0
;
}
}
/* 更新数据库 */
/* 更新数据库 */
var
sign_data
=
{
uid
:
uid
,
pkuid
:
pkuid
,
type
:
0
};
var
sign_data
=
{
uid
:
uid
,
pkuid
:
pkuid
,
type
:
0
};
var
sign
=
setSign
(
sign_data
);
var
sign
=
setSign
(
sign_data
);
request
(
config
[
'WEBADDRESS'
]
+
"?service=Livepk.changeLive&uid="
+
uid
+
"&pkuid="
+
pkuid
+
"&type=0&sign="
+
sign
,
function
(
error
,
response
,
body
){});
request
(
config
[
'WEBADDRESS'
]
+
"?service=Livepk.changeLive&uid="
+
uid
+
"&pkuid="
+
pkuid
+
"&type=0&sign="
+
sign
,
function
(
error
,
response
,
body
){});
LiveConnect
[
uid
]
=
0
;
LiveConnect
[
uid
]
=
0
;
LiveConnect
[
pkuid
]
=
0
;
LiveConnect
[
pkuid
]
=
0
;
// console.log('endLiveConnect');
// console.log('endLiveConnect');
// console.log(uid);
// console.log(uid);
// console.log(pkuid);
// console.log(pkuid);
clientRedis
.
hset
(
'LiveConnect'
,
uid
,
0
);
clientRedis
.
hset
(
'LiveConnect'
,
uid
,
0
);
clientRedis
.
hset
(
'LiveConnect'
,
pkuid
,
0
);
clientRedis
.
hset
(
'LiveConnect'
,
pkuid
,
0
);
if
(
LivePK_timer
[
pkuid
]){
if
(
LivePK_timer
[
pkuid
]){
clearTimeout
(
LivePK_timer
[
pkuid
]);
clearTimeout
(
LivePK_timer
[
pkuid
]);
LivePK_timer
[
pkuid
]
=
null
;
LivePK_timer
[
pkuid
]
=
null
;
}
}
/* 清除PK信息 */
/* 清除PK信息 */
LivePK
[
uid
]
=
0
;
LivePK
[
uid
]
=
0
;
LivePK
[
pkuid
]
=
0
;
LivePK
[
pkuid
]
=
0
;
LivePK_gift
[
uid
]
=
0
;
LivePK_gift
[
uid
]
=
0
;
LivePK_gift
[
pkuid
]
=
0
;
LivePK_gift
[
pkuid
]
=
0
;
clientRedis
.
hset
(
'LivePK'
,
uid
,
0
);
clientRedis
.
hset
(
'LivePK'
,
uid
,
0
);
clientRedis
.
hset
(
'LivePK'
,
pkuid
,
0
);
clientRedis
.
hset
(
'LivePK'
,
pkuid
,
0
);
clientRedis
.
hset
(
'LivePK_gift'
,
uid
,
0
);
clientRedis
.
hset
(
'LivePK_gift'
,
uid
,
0
);
clientRedis
.
hset
(
'LivePK_gift'
,
pkuid
,
0
);
clientRedis
.
hset
(
'LivePK_gift'
,
pkuid
,
0
);
var
data_obj
=
{
var
data_obj
=
{
"msg"
:[
"msg"
:[
{
{
...
@@ -1030,21 +1030,21 @@ function endLiveConnect(io,uid){
...
@@ -1030,21 +1030,21 @@ function endLiveConnect(io,uid){
"retcode"
:
"000000"
,
"retcode"
:
"000000"
,
"retmsg"
:
"OK"
"retmsg"
:
"OK"
};
};
process_msg
(
io
,
uid
,
JSON
.
stringify
(
data_obj
));
process_msg
(
io
,
uid
,
JSON
.
stringify
(
data_obj
));
process_msg
(
io
,
pkuid
,
JSON
.
stringify
(
data_obj
));
process_msg
(
io
,
pkuid
,
JSON
.
stringify
(
data_obj
));
}
}
/* PK结束处理 */
/* PK结束处理 */
function
endLivePk
(
io
,
uid
,
type
){
function
endLivePk
(
io
,
uid
,
type
){
if
(
LivePK_timer
[
uid
]){
if
(
LivePK_timer
[
uid
]){
clearTimeout
(
LivePK_timer
[
uid
]);
clearTimeout
(
LivePK_timer
[
uid
]);
LivePK_timer
[
uid
]
=
null
;
LivePK_timer
[
uid
]
=
null
;
}
}
clientRedis
.
hdel
(
'LivePK_timer'
,
uid
);
clientRedis
.
hdel
(
'LivePK_timer'
,
uid
);
var
win_uid
=
0
;
var
win_uid
=
0
;
var
pkuid
=
LivePK
[
uid
];
var
pkuid
=
LivePK
[
uid
];
if
(
!
pkuid
||
pkuid
<=
0
){
if
(
!
pkuid
||
pkuid
<=
0
){
...
@@ -1052,12 +1052,12 @@ function endLivePk(io,uid,type){
...
@@ -1052,12 +1052,12 @@ function endLivePk(io,uid,type){
}
}
var
end_gift_uid
=
LivePK_gift
[
uid
];
var
end_gift_uid
=
LivePK_gift
[
uid
];
var
end_gift_pkuid
=
LivePK_gift
[
pkuid
];
var
end_gift_pkuid
=
LivePK_gift
[
pkuid
];
if
(
LivePK_timer
[
pkuid
]){
if
(
LivePK_timer
[
pkuid
]){
clearTimeout
(
LivePK_timer
[
pkuid
]);
clearTimeout
(
LivePK_timer
[
pkuid
]);
LivePK_timer
[
pkuid
]
=
null
;
LivePK_timer
[
pkuid
]
=
null
;
}
}
if
(
type
==
1
){
if
(
type
==
1
){
win_uid
=
pkuid
;
win_uid
=
pkuid
;
}
else
if
(
end_gift_uid
>
end_gift_pkuid
){
}
else
if
(
end_gift_uid
>
end_gift_pkuid
){
...
@@ -1065,14 +1065,14 @@ function endLivePk(io,uid,type){
...
@@ -1065,14 +1065,14 @@ function endLivePk(io,uid,type){
}
else
if
(
end_gift_uid
<
end_gift_pkuid
){
}
else
if
(
end_gift_uid
<
end_gift_pkuid
){
win_uid
=
pkuid
;
win_uid
=
pkuid
;
}
}
/* 清除PK信息 */
/* 清除PK信息 */
LivePK
[
uid
]
=
0
;
LivePK
[
uid
]
=
0
;
LivePK
[
pkuid
]
=
0
;
LivePK
[
pkuid
]
=
0
;
LivePK_gift
[
uid
]
=
0
;
LivePK_gift
[
uid
]
=
0
;
LivePK_gift
[
pkuid
]
=
0
;
LivePK_gift
[
pkuid
]
=
0
;
// console.log('endLivePk');
// console.log('endLivePk');
// console.log(type);
// console.log(type);
// console.log(uid);
// console.log(uid);
...
@@ -1081,13 +1081,13 @@ function endLivePk(io,uid,type){
...
@@ -1081,13 +1081,13 @@ function endLivePk(io,uid,type){
// console.log(time);
// console.log(time);
// console.log(end_gift_uid);
// console.log(end_gift_uid);
// console.log(end_gift_pkuid);
// console.log(end_gift_pkuid);
clientRedis
.
hset
(
'LivePK'
,
uid
,
0
);
clientRedis
.
hset
(
'LivePK'
,
uid
,
0
);
clientRedis
.
hset
(
'LivePK'
,
pkuid
,
0
);
clientRedis
.
hset
(
'LivePK'
,
pkuid
,
0
);
clientRedis
.
hset
(
'LivePK_gift'
,
uid
,
0
);
clientRedis
.
hset
(
'LivePK_gift'
,
uid
,
0
);
clientRedis
.
hset
(
'LivePK_gift'
,
pkuid
,
0
);
clientRedis
.
hset
(
'LivePK_gift'
,
pkuid
,
0
);
var
data_obj
=
{
var
data_obj
=
{
"msg"
:[
"msg"
:[
{
{
...
@@ -1102,7 +1102,7 @@ function endLivePk(io,uid,type){
...
@@ -1102,7 +1102,7 @@ function endLivePk(io,uid,type){
"retcode"
:
"000000"
,
"retcode"
:
"000000"
,
"retmsg"
:
"OK"
"retmsg"
:
"OK"
};
};
process_msg
(
io
,
uid
,
JSON
.
stringify
(
data_obj
));
process_msg
(
io
,
uid
,
JSON
.
stringify
(
data_obj
));
process_msg
(
io
,
pkuid
,
JSON
.
stringify
(
data_obj
));
process_msg
(
io
,
pkuid
,
JSON
.
stringify
(
data_obj
));
}
}
...
@@ -1126,7 +1126,7 @@ function setSign(obj) {//排序的函数
...
@@ -1126,7 +1126,7 @@ function setSign(obj) {//排序的函数
str
+=
newkey
[
i
]
+
'='
+
obj
[
newkey
[
i
]]
+
'&'
;
str
+=
newkey
[
i
]
+
'='
+
obj
[
newkey
[
i
]]
+
'&'
;
}
}
str
+=
config
[
'sign_key'
];
str
+=
config
[
'sign_key'
];
var
sign
=
md5
(
str
);
var
sign
=
md5
(
str
);
return
sign
;
return
sign
;
}
}
api/Appapi/Model/Live.php
View file @
39d7cbf2
...
@@ -432,7 +432,7 @@ class Model_Live extends PhalApi_Model_NotORM {
...
@@ -432,7 +432,7 @@ class Model_Live extends PhalApi_Model_NotORM {
$ids
=
DI
()
->
notorm
->
users_zombie
$ids
=
DI
()
->
notorm
->
users_zombie
->
select
(
'uid'
)
->
select
(
'uid'
)
->
where
(
"uid not in (
{
$where
}
)"
)
->
where
(
"uid not in (
{
$where
}
)"
)
->
limit
(
0
,
10
)
->
limit
(
0
,
4
)
->
fetchAll
();
->
fetchAll
();
$info
=
array
();
$info
=
array
();
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment