Created
June 16, 2019 07:15
-
-
Save iainnash/0b8224f3252610544ae95f9b3c78811b to your computer and use it in GitHub Desktop.
This file contains 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
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