You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

38 lines
974 B

import { WebSocketClient as WSClient } from "@autoplex/websocket-client";
import { IMovieProgressResponse, WebSocketMethod } from "@autoplex-api/interface";
import store, { Action } from "./store";
class WebSocketClient extends WSClient
{
/**
* Setup the socket
*/
protected setup() {
store.watch(state => state.user, () => this.authStateChanged());
}
/**
* 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);
}
// Public Interface ----------------------------------------------------------------------------
/**
* Get the progress of the given movies
*/
public async movieProgress(ticketIds: number[]) {
return await this.request<IMovieProgressResponse>(WebSocketMethod.TicketProgress, ticketIds);
}
}
export default new WebSocketClient(`ws://${document.domain}:3250/`);