Last active
May 9, 2017 16:13
-
-
Save nikitaeverywhere/7d1ebc13962a2a462a18ec15deac65d7 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
/** | |
* Just a piece of code to start. | |
*/ | |
const host = "127.0.0.1:57772"; | |
let ws = new WebSocket(`ws://${ host }/csp/user/WebCourse.ChatWebSocket.cls`); | |
ws.addEventListener(`open`, () => { | |
console.log(`We are connected to the chat!`); | |
}); | |
ws.addEventListener(`error`, (err) => { | |
console.error(`Connection error:`, err); | |
}); | |
ws.addEventListener(`close`, () => { | |
console.log(`We are disconnected from the chat.`); | |
}); | |
ws.addEventListener(`message`, ({ data }) => { | |
console.log(`Data received from the server:`, JSON.stringify(data)); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment