Skip to content

Instantly share code, notes, and snippets.

@hediet hediet/demo.ts
Created Mar 15, 2019

Embed
What would you like to do?
// shared
export const debuggerProxyContract = contract({
server: {
keepAlive: notificationContract({}),
},
client: {
serverStarted: notificationContract({ params: type({ port: number }) }),
clientConnected: notificationContract({}),
},
});
// client
const proc = spawn("node", ["server.js"]);
const { server } = debuggerProxyContract.getServerFromStream(
NodeJsMessageStream.connectToProcess(proc),
undefined,
{
serverStarted: ({ port }) => {
// ...
},
clientConnected: () => {
// ...
}
}
);
// server
const { client } = debuggerProxyContract.registerServerToStream(
NodeJsMessageStream.connectToThisProcess(),
{
keepAlive: () => {
timeout.reset();
},
}
);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.