pubnub / pubnub-xkcd

http://twitter.com/stephenlb - PubNub Powered xkcd MMO World Game. Live with WebSockets and rendered with HTML5 Canvas.
56 stars 9 forks source link

Exclude updates from/to users out of view. #5

Open JTxt opened 11 years ago

JTxt commented 11 years ago

As suggested on HN:

http://news.ycombinator.com/item?id=4584820 I'm talking about dividing the map into multiple channels so that users only receives updates from those around them, and hopefully make it more responsive. So for 1000x1000 areas, if I'm at "x":3033521.3,"y":-3025356.4, my client subscribes to /xkcd_x3033_y-3025 And adjoining area/channels if they're close to a border. (but only sends updates to the current area/channel.) ...IF it's easy enough for the client to dynamically change channels, and be subscribed to multiple (up to 4) channels. Then combine this with multiple spawn locations at other interesting locations when demand is high. But they can still explore and meet others. So it should more responsive and less data sent than everyone getting updates from everyone.


Is it possible and practical for clients to be subscribed to multiple channels, and change channels every few seconds as they navigate? If there is a large overhead changing channels, perhaps have dynamic sector sizes using quadtrees.

Clients should not send updates if there is noone else in that sector. (User sends a PING to new sector, if it receives no PONGS, no need to send updates of location? Perhaps this should be integrated into a way to determine the number of users in a channel. (Related to issue #2 ) or PUBNUB keeps track of that?)

I have not had time and may not have time to work on this, but perhaps these thoughts will be helpful to this or future projects.

stephenlb commented 11 years ago

@JTxt, yes good point! The animation is based on velocity and client calculation of anticipated location. However this type of animation rarely is affective in a networked environment. Best bet is to use tweening and latest x/y coord positioning. This way users won't skip around as you are seeing. Check out this great live example here - http://www.pubnub.com/ - click "PubNub in Action". This is the type of animation that makes more sense.