import { WebSocketClient as WSClient } from "@autoplex/websocket-client";
|
|
import store, { Action } from "./store";
|
|
|
|
class WebSocketClient extends WSClient
|
|
{
|
|
/**
|
|
* Setup the socket
|
|
*/
|
|
protected setup() {
|
|
store.watch(state => state.user, () => this.authStateChanged());
|
|
setTimeout(async () => {
|
|
let result = await this.request("test", "snthaoeu onstehu soehu soeuh ou");
|
|
console.log("The result is:", result);
|
|
}, 5000);
|
|
}
|
|
|
|
/**
|
|
* Get the app's current auth JWT
|
|
*/
|
|
protected jwt() {
|
|
return store.state.user?.token ?? null;
|
|
}
|
|
|
|
/**
|
|
* Forget the JWT and log out of the app
|
|
*/
|
|
protected forgetJwt() {
|
|
store.dispatch(Action.AuthForget, undefined);
|
|
}
|
|
}
|
|
|
|
export default new WebSocketClient("ws://localhost:3250/");
|