Skip to content

Instantly share code, notes, and snippets.

@miketamis
Created February 3, 2017 03:43
Show Gist options
  • Save miketamis/2af70fd876f3a1a44b052f432ce43b20 to your computer and use it in GitHub Desktop.
Save miketamis/2af70fd876f3a1a44b052f432ce43b20 to your computer and use it in GitHub Desktop.

Create connection via calling Transport with IP

const transport = Transport('192.168.1.1');

To write a message over the socket use write, this will return a promise. The promise will only resolve if an ack is recieved.

transport.write('Hello how are you doing').then(() => {
  console.log('message sent properly');
});

You can listen to message from the server through .listen, this is a callback with the message.

transport.listen((message) => {
  console.log('Message from server', message);
});

to disconnect do disconnect :D

transport.disconnect()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment