nicobarray / aquedux

Redux over the wire
46 stars 3 forks source link

Handle an aquedux-specific key in all actions #37

Open nicobarray opened 6 years ago

nicobarray commented 6 years ago

When an action is sent over the wire, we should add the aquedux key to it and it should contains the following keys:

{
    token: localStorage.getItem('aquedux-jwt'),
}

When we receive an action from the server it should have the following keys:

{
    token,
    server: {
       enterTimestamp: number,
       leaveTimestamp: number
    },
}

The user-side timestamps are useless tho because they would be only valid for the action sender to compute the action roundtrip is needed:

totalDuration =  client.receiveTimestamp - client.sendTimestamp;
serverDuration =  server.leaveTimestamp - server.enterTimestamp;
roundtripDuration = (totalDuration - serverDuration) / 2