11. Vue 2 - SockJS
OS | Windows 10 Home 64bit 버전 1903 (OS 빌드 18362.836) |
Vue | 2.5.13 |
# sock (서버)와 sock-client (클라이언트)로 나뉜다
메소드 | 설명 |
onopen | 서버와 연결 됐을 때 호출 |
onmessage | 클라이언트가 서버로부터 메시지를 받을 때 호출 |
onclose | 웹 소켓 연결이 종료됐을 때 호출 |
onerror | 에러가 발생하면 호출 |
send | 서버로 데이터 전송 (blob, ArrayBuffer, ArrayBufferView) |
close | 클라이언트와 서버 통신 종료 |
HTML Standard
This section is non-normative. To enable web applications to maintain bidirectional communications with server-side processes, this specification introduces the WebSocket interface. This interface does not allow for raw access to the underlying network. Fo
html.spec.whatwg.org
/** 서버와 연결 됐을 때 호출 */
socket.onopen = function (event) {
console.log(event)
console.log(socket.readyState)
}
/** 클라이언트가 서버로부터 메시지를 받을 때 호출 */
socket.onmessage = function (message) {
console.log(message)
}
/** 웹 소켓 연결이 종료됐을 때 호출 */
socket.onclose = function (event) {
console.log(event)
}
/** 에러가 발생하면 호출 */
socket.onerror = function (error) {
console.log(error)
}
'16. Vue JS > Vue 2' 카테고리의 다른 글
14. Vue 2 - Vue Storybook (0) | 2021.03.31 |
---|---|
인프런 - Vue.js 끝장내기 - 실무에 필요한 모든 것 (0) | 2021.03.29 |
10. Vue 2 - json-viewer (0) | 2020.09.24 |
09. Vue 2 - vuedraggable 2.24 (4) | 2020.09.24 |
08. Vue 2 - Router 현재 페이지 갱신 (0) | 2020.09.23 |
댓글
이 글 공유하기
다른 글
-
14. Vue 2 - Vue Storybook
14. Vue 2 - Vue Storybook
2021.03.31 -
인프런 - Vue.js 끝장내기 - 실무에 필요한 모든 것
인프런 - Vue.js 끝장내기 - 실무에 필요한 모든 것
2021.03.29 -
10. Vue 2 - json-viewer
10. Vue 2 - json-viewer
2020.09.24 -
09. Vue 2 - vuedraggable 2.24
09. Vue 2 - vuedraggable 2.24
2020.09.24