diff --git a/parts/player/player.lua b/parts/player/player.lua index 1391847a..bd8fc14d 100644 --- a/parts/player/player.lua +++ b/parts/player/player.lua @@ -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 diff --git a/parts/scenes/net_chat.lua b/parts/scenes/net_chat.lua index bd3cde29..eb8f2af7 100644 --- a/parts/scenes/net_chat.lua +++ b/parts/scenes/net_chat.lua @@ -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() diff --git a/parts/scenes/net_game.lua b/parts/scenes/net_game.lua index e717d4fc..23d3683f 100644 --- a/parts/scenes/net_game.lua +++ b/parts/scenes/net_game.lua @@ -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) diff --git a/parts/scenes/net_rooms.lua b/parts/scenes/net_rooms.lua index b99b6749..7f475b1d 100644 --- a/parts/scenes/net_rooms.lua +++ b/parts/scenes/net_rooms.lua @@ -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",