换新准备和录像流传输的代码

This commit is contained in:
MrZ626
2021-04-05 21:41:59 +08:00
parent 046a41177f
commit 56bbd269c9

View File

@@ -208,17 +208,22 @@ function scene.socketRead(cmd,data)
resetGameData("qn") resetGameData("qn")
end end
elseif cmd=="Ready"then elseif cmd=="Ready"then
local L=PLY_ALIVE if data.uid==USER.id then
for i=1,#L do PLAYERS[1].ready=true
if L[i].subID==data.uid then SFX.play("reach",.6)
L[i].ready=true else
SFX.play("reach",.6) for i=1,#PLAYERS do
break if PLAYERS[i].userID==data.uid then
PLAYERS[i].ready=true
SFX.play("reach",.6)
break
end
end end
end end
elseif cmd=="Set"then elseif cmd=="Set"then
NET.rsid=data.rid NET.rsid=data.rid
NET.wsConnectStream() NET.wsConnectStream()
TASK.new(NET.updateWS_stream)
elseif cmd=="Begin"then elseif cmd=="Begin"then
if not playing then if not playing then
playing=true playing=true
@@ -235,9 +240,13 @@ function scene.socketRead(cmd,data)
elseif cmd=="Die"then elseif cmd=="Die"then
LOG.print("One player failed",COLOR.sky) LOG.print("One player failed",COLOR.sky)
elseif cmd=="Stream"then elseif cmd=="Stream"then
if playing and data.uid~=PLAYERS[1].subID then if data.uid==USER.id then
LOG.print("SELF STREAM")
return
end
if playing then
for _,P in next,PLAYERS do for _,P in next,PLAYERS do
if P.subID==data.uid then if P.userID==data.uid then
local res,stream=pcall(love.data.decode,"string","base64",data.stream) local res,stream=pcall(love.data.decode,"string","base64",data.stream)
if res then if res then
pumpRecording(stream,P.stream) pumpRecording(stream,P.stream)