Skip to content

Instantly share code, notes, and snippets.

@iainnash
Created June 16, 2019 07:15
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save iainnash/0b8224f3252610544ae95f9b3c78811b to your computer and use it in GitHub Desktop.
Save iainnash/0b8224f3252610544ae95f9b3c78811b to your computer and use it in GitHub Desktop.
ws = new WebSocket('ws://localhost:5401')
componentDidMount() {
this.ws.onopen = () => {
this.ws.onmessage = (m) => console.log(JSON.parse(m.data))
};
}
componentWillUnmount() {
this.ws.close();
}
ws.send(JSON.stringify({command: 'stop'}))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment