Reset state on client connection instead of as a special manipulation of the local server.
This commit is contained in:
parent
7c06ab473d
commit
c620e4c982
3 changed files with 8 additions and 6 deletions
|
@ -92,6 +92,11 @@ export abstract class LockstepClient<LocalInput, GlobalInput, State> {
|
|||
}
|
||||
});
|
||||
|
||||
// talkback should exist at this point, send reset message
|
||||
if(this.serverTalkback) {
|
||||
this.serverTalkback(1, {t: MessageTypes.SET_STATE, s: {}});
|
||||
}
|
||||
|
||||
// disposal
|
||||
return () => {
|
||||
this.serverTalkback?.(2);
|
||||
|
|
|
@ -39,6 +39,9 @@ export class LoopbackServer<LocalInput, State> {
|
|||
this.inputBuffer[playerNumber] = message.i;
|
||||
}
|
||||
break;
|
||||
case MessageTypes.SET_STATE:
|
||||
this.broadcast(1, { t: MessageTypes.SET_STATE, u: -1, s: message.s });
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -52,8 +55,4 @@ export class LoopbackServer<LocalInput, State> {
|
|||
return message;
|
||||
}
|
||||
}
|
||||
|
||||
public resetState(newState: Partial<State>) {
|
||||
this.broadcast(1, { t: MessageTypes.SET_STATE, u: -1, s: newState });
|
||||
}
|
||||
}
|
||||
|
|
|
@ -20,6 +20,4 @@ const server = new LoopbackServer<KeyName[], Data>();
|
|||
|
||||
Select(".GameCanvas").forEachCanvas((c, cx, keys) => new Main(c, cx, keys, server));
|
||||
|
||||
server.resetState({});
|
||||
|
||||
BindTests();
|
||||
|
|
Loading…
Reference in a new issue