Skip to content
This repository has been archived by the owner on Jun 10, 2022. It is now read-only.

Commit

Permalink
Fix animation sync (#180)
Browse files Browse the repository at this point in the history
  • Loading branch information
eanders-ms authored Feb 7, 2019
1 parent d9da226 commit 4069631
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 7 deletions.
4 changes: 2 additions & 2 deletions packages/sdk/src/adapters/multipeer/protocols/clientSync.ts
Original file line number Diff line number Diff line change
Expand Up @@ -209,9 +209,9 @@ export class ClientSync extends Protocols.Protocol {
// client, now pass it to the joining client.
for (const animationState of payload.animationStates) {
// Account for latency on the authoritative peer's connection.
animationState.animationTime += authoritativeClient.conn.quality.latencyMs.value / 2000;
animationState.state.time += authoritativeClient.conn.quality.latencyMs.value / 2000;
// Account for latency on the joining peer's connection.
animationState.animationTime += this.conn.quality.latencyMs.value / 2000;
animationState.state.time += this.conn.quality.latencyMs.value / 2000;
}
super.sendPayload(payload);
resolve();
Expand Down
8 changes: 4 additions & 4 deletions packages/sdk/src/protocols/protocol.ts
Original file line number Diff line number Diff line change
Expand Up @@ -64,15 +64,15 @@ export class Protocol extends EventEmitter {
}

public startListening() {
log.verbose('network', `${this.name} started listening`);
log.debug('network', `${this.name} started listening`);
this.conn.on('recv', this.onReceive);
this.conn.on('close', this.onClose);
}

public stopListening() {
this.conn.off('recv', this.onReceive);
this.conn.off('close', this.onClose);
log.verbose('network', `${this.name} stopped listening`);
log.debug('network', `${this.name} stopped listening`);
}

public sendPayload(payload: Partial<Payload>, promise?: ExportedPromise) {
Expand Down Expand Up @@ -181,8 +181,8 @@ export class Protocol extends EventEmitter {
protected handleReplyMessage(message: Message) {
const queuedPromise = this.promises[message.replyToId];
if (!queuedPromise) {
// tslint:disable-next-line:no-console
console.error(`[ERROR] ${this.name} received unexpected reply message! replyToId: ${message.replyToId}`);
// tslint:disable-next-line:no-console max-line-length
console.error(`[ERROR] ${this.name} received unexpected reply message! payload: ${message.payload.type}, replyToId: ${message.replyToId}`);
} else {
delete this.promises[message.replyToId];
clearTimeout(queuedPromise.timeout);
Expand Down
2 changes: 1 addition & 1 deletion packages/sdk/src/types/network/payloads/payloads.ts
Original file line number Diff line number Diff line change
Expand Up @@ -356,7 +356,7 @@ export type SetAnimationState = Payload & {
*/
export type SyncAnimations = Payload & {
type: 'sync-animations';
animationStates: AnimationState[];
animationStates: SetAnimationState[];
};

/**
Expand Down

0 comments on commit 4069631

Please sign in to comment.