Really cool approaches guys! I think I can handle to code them, let's go! Thank you all very much!!! :)
On Aug 22, 2:07 am, Shripad K <[email protected]> wrote: > You can do this perhaps (If persistence is not a major requirement): > > When socket connects fetch from DB the stored points and store it in an > object (perhaps a global object with the key being the unique ID of the > user). Then for each message relayed to the server from client (be it > upvote or from any other place) increment points inside the object (without > hitting the DB). If you have multiple nodes use IPC to make sure that this > object is synchronized across all nodes (if required). When the socket > disconnect event is emitted, store the final object to the DB making it > persistent. If the upvote is for another user, then still > onconnect/onmessage load the stored points for the other user from the DB > (if not already in the global object) into the global object and repeat the > same steps as above. > > > > > > > > On Wed, Aug 22, 2012 at 8:11 AM, Michael W <[email protected]> wrote: > > Sure, but those are lower frequency and you likely don't mind hitting > > the database when they happen. > > > I recommend splitting your "events" into two categories: > > > - Real-time events that the server must take care to relay properly > > - Client-side events that the server remembers and has final say but are > > only "real-time visible" / managed by the client > > > If a real-time event (liking a message) happens, send it to the client > > straightaway; then the client can just add that to their immediate > > score. When the server needs to calculate this score, it can just be the > > sum of the realtime events (sum of likes) plus however many seconds > > elapsed since they log in; this is a constant cost. > > > On Tue, 21 Aug 2012 15:18:55 -0700 (PDT), Filipe <[email protected]> > > wrote: > > > Michael, that will fit perfect disconsidering the fact that this user > > > can receive external points from other signals (ie someone else liking > > > your message) :( > > > > On Aug 21, 7:14 pm, Michael W <[email protected]> wrote: > > > > Why can't you track this on the client side? > > > > > - Have the server side calculate points when it detects that their > > > > connection drops > > > > > - Each client additionally runs a 1-second timer that updates the point > > > > display without hitting the server, understanding that the server has > > > > final say in how many points the account has. > > > > > On Tue, 21 Aug 2012 14:55:01 -0700 (PDT), Filipe <[email protected]> > > wrote: > > > > > Douglas, yes, time is one of the score signals (the main one). > > > > > > Anyway, I can't picture how can I make this sync on client side > > > > > without always hitting DB to check how many point do user have in > > that > > > > > specific interaction/time. > > > > > > For exemple, these interactions: > > > > > > 1) Initial points 100 (client side: 100 points) > > > > > 2) 1 second passes: +1 point (client side: 101 points) > > > > > 3) 1 second passes: +1 point (client side: 102 points) > > > > > 4) Friend like my message AND 1 second passes: +1 +1 points (client > > > > > side: 104 points) > > > > > > Hitting DB > > > > > 1) 1 hit -> emit('points') > > > > > 2) 1 hit -> emit('points') > > > > > 3) 1 hit -> emit('points') > > > > > 4) 2 hits -> emit('points') x 2 > > > > > > Is this correct? > > > > > > On Aug 21, 3:17 pm, "P. Douglas Reeder" <[email protected]> wrote: > > > > > > It sounds like you have a score, rather than strictly time > > connected. That's an aggregate, so using Mongo's map-reduce should adapt to > > different ways of measuring time connected (if you find your current > > measurement takes too many resources). It should also be efficient, since > > only changed factors are recomputed. > > > > > > -- > > > > > Job Board:http://jobs.nodejs.org/ > > > > > Posting guidelines: > >https://github.com/joyent/node/wiki/Mailing-List-Posting-Guidelines > > > > > You received this message because you are subscribed to the Google > > > > > Groups "nodejs" group. > > > > > To post to this group, send email to [email protected] > > > > > To unsubscribe from this group, send email to > > > > > [email protected] > > > > > For more options, visit this group at > > > > >http://groups.google.com/group/nodejs?hl=en?hl=en > > > > -- > > > Job Board:http://jobs.nodejs.org/ > > > Posting guidelines: > >https://github.com/joyent/node/wiki/Mailing-List-Posting-Guidelines > > > You received this message because you are subscribed to the Google > > > Groups "nodejs" group. > > > To post to this group, send email to [email protected] > > > To unsubscribe from this group, send email to > > > [email protected] > > > For more options, visit this group at > > >http://groups.google.com/group/nodejs?hl=en?hl=en > > > -- > > Job Board:http://jobs.nodejs.org/ > > Posting guidelines: > >https://github.com/joyent/node/wiki/Mailing-List-Posting-Guidelines > > You received this message because you are subscribed to the Google > > Groups "nodejs" group. > > To post to this group, send email to [email protected] > > To unsubscribe from this group, send email to > > [email protected] > > For more options, visit this group at > >http://groups.google.com/group/nodejs?hl=en?hl=en -- Job Board: http://jobs.nodejs.org/ Posting guidelines: https://github.com/joyent/node/wiki/Mailing-List-Posting-Guidelines You received this message because you are subscribed to the Google Groups "nodejs" group. To post to this group, send email to [email protected] To unsubscribe from this group, send email to [email protected] For more options, visit this group at http://groups.google.com/group/nodejs?hl=en?hl=en
