Skip to content

Instantly share code, notes, and snippets.

@sethdorris
Last active May 4, 2016 15:36
Show Gist options
  • Save sethdorris/b6164a64ae18a7f13c1cbcca1bc39911 to your computer and use it in GitHub Desktop.
Save sethdorris/b6164a64ae18a7f13c1cbcca1bc39911 to your computer and use it in GitHub Desktop.
let ws = new WebSocket("ws://localhost:3000");
const server = {
connected: false,
connect: function() {
console.log("Connected", this.connected);
ws.onopen = () => {
console.log("CONNECTED!");
}
ws.onerror = (e) => {
console.log("Error", e);
}
return this.connected;
},
sendmessage: () => {
ws.send(JSON.stringify({message: "hi"}));
}
}
export default server;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment