It looks like you're new here. If you want to get involved, click one of these buttons!
seqNo = 0 userInTurn = 0 while (true) if receive_submit() then seqNo = seqNo + 1 userInTurn = get_next_turn() end update_game_logic() deliver_to_all_clients(seqNo, userInTurn, gamedata) end |
seqNo = -1 function On_Receive_Data_Update(ServerSeqNo, currentTurnIndex, gamedata) if ServerSeqNo >= seqNo then -- valid seq if ServerSeqNo > seqNo -- change state if state is LOCK then if currentTurnIndex == turnIndex then switch_to_state(INPUT) end elseif state is INPUT then if currentTurnIndex != turnIndex then switch_to_state(LOCK) end else if currentTurnIndex == turnIndex then switch_to_state(INPUT) else switch_to_state(LOCK) end end end update_game_with_data(gamedata) end end function update_client_control() if state is INPUT then update_game_input() if hasEndTurn() then submit() end end end |
Likes: TheOddLinguist
Comments
I think hole punching is (only) useful when you need to send large amount of data (such as file transfer or audio/video communication) between clients. Otherwise, communication through a server is preferable.
+ I wanna keep server in low CPU (discovery & forward only) so could increase CCU
+ If one server is not enough, I can use another one easily (they take role as client discovery and message forwarder at not, not game logic)
+ developer can develop game in client, no need server code (for simple game)
+ udp (or tcp) punch keeps traffic transfer thought server down
Is it weird ?
@gorkem: I send one data package per second.
About push notification, you means local or remote notification? I don't know how does it work in this case
not weird but insane
Centralized systems also have some advantages like:
- it's easy to modify game logic
- it's hard to cheat