Created
March 15, 2019 09:50
-
-
Save hediet/4911f69320a4e1904a3fb2f6059f2372 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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