socket-client-plugin

1.0.5 • Public • Published

vue-socket

use

npm install socket-client-plugin

For example in vue

registry socket-client inside your app entrypoint (for vue)

main.js

import Vue from 'vue'
import socketClientPlugin from 'socket-client-plugin'

Vue.use(socketClientPlugin)

use in any components (for vue)

this.$socket.createSocket(url [, protocols])    // create websocket

this.$socket.onEvent("socket-open", (event) => {
    // socket open do...
})
this.$socket.onEvent("socket-close", (event) => {
    // socket close do...
})
this.$socket.onEvent("socket-message", (event) => {
    // socket message do...
})
this.$socket.onEvent("socket-error", (event) => {
    // socket error do...
})

// Actively close the socket
this.$socket.close()

// send any
this.$socket.send("any message")

Package Sidebar

Install

npm i socket-client-plugin

Weekly Downloads

1

Version

1.0.5

License

ISC

Unpacked Size

5.09 kB

Total Files

6

Last publish

Collaborators

  • lixueshiaa