整理代码
This commit is contained in:
@@ -104,6 +104,23 @@ local function removePlayer(L,sid)
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
--Push stream data to players
|
||||||
|
local function pumpStream(d)
|
||||||
|
if d.uid~=USER.uid then
|
||||||
|
for _,P in next,PLAYERS do
|
||||||
|
if P.uid==d.uid then
|
||||||
|
local res,stream=pcall(love.data.decode,'string','base64',d.stream)
|
||||||
|
if res then
|
||||||
|
DATA.pumpRecording(stream,P.stream)
|
||||||
|
else
|
||||||
|
LOG.print("Bad stream from "..P.username.."#"..P.uid,10)
|
||||||
|
end
|
||||||
|
break
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
--Connect
|
--Connect
|
||||||
function NET.wsconn_app()
|
function NET.wsconn_app()
|
||||||
WS.connect('app','/app')
|
WS.connect('app','/app')
|
||||||
@@ -554,8 +571,10 @@ function NET.updateWS_stream()
|
|||||||
if d.spectate then
|
if d.spectate then
|
||||||
if d.start then
|
if d.start then
|
||||||
SCN.socketRead('go')
|
SCN.socketRead('go')
|
||||||
for _,v in next,d.history or{}do
|
if d.history then
|
||||||
SCN.socketRead('stream',v)
|
for _,v in next,d.history do
|
||||||
|
pumpStream(v)
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
@@ -578,7 +597,7 @@ function NET.updateWS_stream()
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
elseif res.action==5 then--Receive stream
|
elseif res.action==5 then--Receive stream
|
||||||
SCN.socketRead('stream',d)
|
pumpStream(d)
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
WS.alert('stream')
|
WS.alert('stream')
|
||||||
|
|||||||
@@ -220,20 +220,6 @@ function scene.socketRead(cmd,d)
|
|||||||
elseif cmd=='finish'then
|
elseif cmd=='finish'then
|
||||||
playing=false
|
playing=false
|
||||||
love.keyboard.setKeyRepeat(true)
|
love.keyboard.setKeyRepeat(true)
|
||||||
elseif cmd=='stream'then
|
|
||||||
if d.uid~=USER.uid then
|
|
||||||
for _,P in next,PLAYERS do
|
|
||||||
if P.uid==d.uid then
|
|
||||||
local res,stream=pcall(love.data.decode,'string','base64',d.stream)
|
|
||||||
if res then
|
|
||||||
DATA.pumpRecording(stream,P.stream)
|
|
||||||
else
|
|
||||||
LOG.print("Bad stream from "..P.username.."#"..P.uid,10)
|
|
||||||
end
|
|
||||||
break
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user