Advertisement
Guest User

Untitled

a guest
Mar 20th, 2019
73
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.68 KB | None | 0 0
  1. // shared
  2. export const debuggerProxyContract = contract({
  3. server: {
  4. keepAlive: notificationContract({}),
  5. },
  6. client: {
  7. serverStarted: notificationContract({ params: type({ port: number }) }),
  8. clientConnected: notificationContract({}),
  9. },
  10. });
  11.  
  12. // client
  13. const proc = spawn("node", ["server.js"]);
  14. const { server } = debuggerProxyContract.getServerFromStream(
  15. NodeJsMessageStream.connectToProcess(proc),
  16. undefined,
  17. {
  18. serverStarted: ({ port }) => {
  19. // ...
  20. },
  21. clientConnected: () => {
  22. // ...
  23. }
  24. }
  25. );
  26.  
  27. // server
  28. const { client } = debuggerProxyContract.registerServerToStream(
  29. NodeJsMessageStream.connectToThisProcess(),
  30. {
  31. keepAlive: () => {
  32. timeout.reset();
  33. },
  34. }
  35. );
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement