{"action":"created","issue":{"url":"https://api.github.com/repos/huytd/agar.io-clone/issues/82","labels_url":"https://api.github.com/repos/huytd/agar.io-clone/issues/82/labels{/name}","comments_url":"https://api.github.com/repos/huytd/agar.io-clone/issues/82/comments","events_url":"https://api.github.com/repos/huytd/agar.io-clone/issues/82/events","html_url":"https://github.com/huytd/agar.io-clone/issues/82","id":83129237,"number":82,"title":"Bad Server/Client Communication Architecture ?","user":{"login":"yueyoum","id":2081686,"avatar_url":"https://avatars.githubusercontent.com/u/2081686?v=3","gravatar_id":"","url":"https://api.github.com/users/yueyoum","html_url":"https://github.com/yueyoum","followers_url":"https://api.github.com/users/yueyoum/followers","following_url":"https://api.github.com/users/yueyoum/following{/other_user}","gists_url":"https://api.github.com/users/yueyoum/gists{/gist_id}","starred_url":"https://api.github.com/users/yueyoum/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/yueyoum/subscriptions","organizations_url":"https://api.github.com/users/yueyoum/orgs","repos_url":"https://api.github.com/users/yueyoum/repos","events_url":"https://api.github.com/users/yueyoum/events{/privacy}","received_events_url":"https://api.github.com/users/yueyoum/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/huytd/agar.io-clone/labels/enhancement","name":"enhancement","color":"84b6eb"},{"url":"https://api.github.com/repos/huytd/agar.io-clone/labels/feedback","name":"feedback","color":"fbca04"},{"url":"https://api.github.com/repos/huytd/agar.io-clone/labels/help%20wanted","name":"help wanted","color":"159818"}],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":3,"created_at":"2015-05-31T16:32:22Z","updated_at":"2015-05-31T21:11:17Z","closed_at":null,"body":"##  1.   player's move need server feedback\r\n\r\nfirst, player send `playerSendTarget` command to server.\r\nthen server got it, calculate the new position, and send back the `serverTellPlayerMove` command to this player.\r\n\r\nafter the server feedback, the player can move.\r\n\r\nIf there is a big lag between player and server,\r\nthe player move will be blocked in a long time.\r\n\r\nThis should be player move first, then got the server feedback, \r\nplayer modify it's position with the server feedback data.\r\n\r\n\r\n## 2. The server broadcast message immediately\r\n\r\nwhen a player move mouse, \r\nthe server will got a `playerSendTarget` command, and `target` data.\r\n\r\nserver do some calculate (eat food, or eat other players),\r\nthen broadcast `serverUpdateAllPlayers` to all connected players.\r\n\r\nThis is a bad design. \r\n\r\nIf there are 100 players connected to the server.\r\nevery player move mouse one times per second.\r\n\r\nIt means, the server will broadcast 100 times in one seconds.\r\nAnd every client will got 100 times messages.\r\n\r\nThis is very overload to both server  and client.\r\n\r\n\r\nThis should be done as the follows:\r\n\r\nServer has a tick rate (maybe 10Hz.   10 times per second) to sync the whole game world to all clients.\r\n(AOI.  (area of interest )  are just ignored right now  )\r\n\r\nplayer send `playerSendTarget` to server immediately.\r\nserver do calculate, and **NOT** broadcast the message to other clients.\r\n\r\nWhen next server tick comes, then send `serverUpdateAllPlayers` to all clients.\r\n\r\nThis can avoid the overload of server and client in a high rate  communicate.\r\nServer To Client rate is Fixed to the server tick rate.\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n"},"comment":{"url":"https://api.github.com/repos/huytd/agar.io-clone/issues/comments/107246981","html_url":"https://github.com/huytd/agar.io-clone/issues/82#issuecomment-107246981","issue_url":"https://api.github.com/repos/huytd/agar.io-clone/issues/82","id":107246981,"user":{"login":"psykzz","id":1134201,"avatar_url":"https://avatars.githubusercontent.com/u/1134201?v=3","gravatar_id":"","url":"https://api.github.com/users/psykzz","html_url":"https://github.com/psykzz","followers_url":"https://api.github.com/users/psykzz/followers","following_url":"https://api.github.com/users/psykzz/following{/other_user}","gists_url":"https://api.github.com/users/psykzz/gists{/gist_id}","starred_url":"https://api.github.com/users/psykzz/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/psykzz/subscriptions","organizations_url":"https://api.github.com/users/psykzz/orgs","repos_url":"https://api.github.com/users/psykzz/repos","events_url":"https://api.github.com/users/psykzz/events{/privacy}","received_events_url":"https://api.github.com/users/psykzz/received_events","type":"User","site_admin":false},"created_at":"2015-05-31T21:11:17Z","updated_at":"2015-05-31T21:11:17Z","body":"I disagree with 1.\r\nWhen testing the original AGAR there was no way for you to take an action if the server was dead. All movement was due to messaging from the server.\r\n\r\nThe only thing controlled client side was the level of zoom.\r\n\r\nWith 2. however, i do believe we need to either restrict the information that is being sent. If we cant proceed with a tickrate then limiting to nearby within range or maybe making only messages sent on a 1/10 of a second are actually sent.\r\n\r\nSo if we are getting requests from 1000's of users, then we only send them to a user, if he is less than 1/10 second. That could be implemented with something like an inverse token bucket."}}