整理代码,把旧的wsWrite函数先改成新的WS.send,非最终稿

This commit is contained in:
MrZ626
2021-02-22 01:10:25 +08:00
parent 7d90a4dcfc
commit a8119bc9dd
4 changed files with 11 additions and 13 deletions

View File

@@ -1752,7 +1752,7 @@ function Player.lose(P,force)
gameOver()
P:newTask(#PLAYERS>1 and tick_lose or tick_finish)
if GAME.net then
wsWrite("D")
WS.send("play","D")
else
TASK.new(tick_autoPause)
end

View File

@@ -12,7 +12,7 @@ local function _init()
end
local function sendMessage()
local W=WIDGET.active.input
if #W.value>0 and wsWrite("T"..data.encode("string","base64",W.value))then
if #W.value>0 and WS.send("chat","T"..data.encode("string","base64",W.value))then
W.value=""
end
end
@@ -31,11 +31,10 @@ function scene.sceneInit()
end
textBox:scroll(1)
TASK.new(_init)--Widgets are not initialized, so active after 1 frame
TASK.new(TICK_wsRead)
BG.set("none")
end
function scene.sceneBack()
wsWrite("Q")
WS.send("chat","Q")
WSCONN=false
LOG.print(text.wsDisconnected,"warn")
end
@@ -90,7 +89,7 @@ function scene.update(dt)
heartBeatTimer=heartBeatTimer+dt
if heartBeatTimer>42 then
heartBeatTimer=0
wsWrite("P")
WS.send("chat","P")
end
end
function scene.draw()

View File

@@ -31,14 +31,13 @@ local touchMoveLastFrame=false
local scene={}
function scene.sceneBack()
wsWrite("Q")
WS.send("play","Q")
WSCONN=false
LOG.print(text.wsDisconnected,"warn")
love.keyboard.setKeyRepeat(true)
end
function scene.sceneInit()
love.keyboard.setKeyRepeat(false)
TASK.new(TICK_wsRead)
hideChatBox=true
playerInitialized=false
textBox:clear()
@@ -110,7 +109,7 @@ function scene.keyDown(key)
end
elseif key=="space"then
if not PLAYERS[1].ready then
wsWrite("R")
WS.send("play","R")
end
end
end
@@ -270,7 +269,7 @@ function scene.update(dt)
heartBeatTimer=heartBeatTimer+dt
if heartBeatTimer>42 then
heartBeatTimer=0
wsWrite("P")
WS.send("play","P")
end
return
end
@@ -293,7 +292,7 @@ function scene.update(dt)
local stream
stream,upstreamProgress=dumpRecording(GAME.rep,upstreamProgress)
if #stream>0 then
wsWrite("S"..data.encode("string","base64",stream))
WS.send("stream",data.encode("string","base64",stream))
else
ins(GAME.rep,GAME.frame)
ins(GAME.rep,0)

View File

@@ -8,7 +8,7 @@ local lastCreateRoomTime=0
local function enterRoom(roomID)
--[[TODO
wsWrite("???",json.encode{
WS.connect("play","/play",json.encode{
email=USER.email,
token=USER.access_token,
id=roomID,
@@ -21,7 +21,7 @@ local function fresh()
lastfreshTime=TIME()
rooms=nil
--[[TODO
wsWrite("???",json.encode{
WS.connect("play","/play",json.encode{
email=USER.email,
access_token=USER.access_token,
})
@@ -48,7 +48,7 @@ function scene.keyDown(k)
elseif k=="n"then
if TIME()-lastCreateRoomTime>26 then
--[[TODO
wsWrite("???",json.encode{
WS.send("room",json.encode{
email=USER.email,
access_token=USER.access_token,
room_name=(USER.name or"???").."'s room",