feat(net): server measures every player's ping and its own step cost, sent with each snapshot
Also fixes the ping message schema (it checked the field t, which is the message type).
This commit is contained in:
@@ -24,7 +24,7 @@
|
||||
// client -> server message schemas: field -> check
|
||||
const C2S = {
|
||||
hello: { v: v => Number.isInteger(v), token: v => isStr(v, 4096) },
|
||||
ping: { t: v => v === undefined || isNum(v) },
|
||||
ping: { t0: v => v === undefined || isNum(v) }, // (t is the message type itself)
|
||||
room: { room: v => FLAGS.includes(v) || v === 'all' },
|
||||
challenge: { to: v => isStr(v) },
|
||||
'challenge.cancel': {},
|
||||
@@ -89,6 +89,7 @@
|
||||
robots,
|
||||
ack: snap.ack ? snap.ack[seat] : 0,
|
||||
away: snap.away ? (seat === 0 ? snap.away.slice() : [snap.away[1], snap.away[0]]) : undefined,
|
||||
rtt: snap.rtt ? (seat === 0 ? snap.rtt.slice() : [snap.rtt[1], snap.rtt[0]]) : undefined, // ping of [me, opponent]
|
||||
result: localResult(seat, snap.result),
|
||||
crane: Object.assign({}, snap.crane, { who: m(snap.crane.who) }),
|
||||
rockets: snap.rockets.map(k => Object.assign({}, k, { owner: m(k.owner) })),
|
||||
|
||||
Reference in New Issue
Block a user