In our implementation, we will create a RealTimeClient class to wrap a SockJS object to provide channel-based communication. We will bind the instance of this client to Vue.prototype.$rt so that all of the Vue components can access the real-time client via the instance's $rt property. The following is an overview of the RealTimeClient class.
Let's have a look at the frontend/src/real-time-client.js file:
import Vue from 'vue'import SockJS from 'sockjs-client'class RealTimeClient { constructor () { ... } init (serverUrl, token) { ... } logout () { ... } connect () { ... } subscribe (channel, handler) { ... } unsubscribe (channel, handler) { ... }}export default new RealTimeClient()
As you can ...