import { Callbag } from "callbag"; import { ClientMessage, MessageTypes, ServerMessage } from "./LockstepClient"; type Client = Callbag, ClientMessage>; export function Loopback(start: number, data?: Client | ClientMessage) { if(start != 0) return; const sink = data as Client; sink(0, (type: number, data?: Client | ClientMessage) => { if(type == 1) { // message from client; just reflect for now const message = data as ClientMessage; switch(message.t) { case MessageTypes.INPUT: sink(1, message); break; } } }); sink(1, {t: MessageTypes.RESET, s: {}}); };