--[[ Gamestates/Multiplayer/Protocol.lua Some functions involved in talking between 2 clients by piernov Comment: maybe useless. ]]-- local Protocol = {} function Protocol.acceptGame(host, peer_id, accept) -- Send an answer to a connection from another player local peer = host:get_peer(peer_id) if accept then peer:send("ACCEPT: YES", 0, "reliable") else peer:send("ACCEPT: NO", 0, "reliable") peer:disconnect_later() end end function Protocol.parseGlobalEvents(event) -- Shared function between local menu and game which disallow multiple connections and handle disconnect if event.type == "connect" then if event.peer:index() > 1 then print("Already connected") event.peer:disconnect(2) end elseif event.type == "disconnect" then print("Disconnect " .. tostring(event.peer)) if event.data == 2 then print("Peer is busy") event.peer:disconnect() end end end return Protocol