|
|
@ -1,4 +1,6 @@ |
|
|
|
import { WebSocketServerService } from "@autoplex/websocket-server"; |
|
|
|
import { WebSocketMethod } from "@autoplex-api/request"; |
|
|
|
import { IpcClient as SeekerIpc } from "@autoplex-api/seeker"; |
|
|
|
import Application from "../Application"; |
|
|
|
|
|
|
|
export default class WebSocketServer extends WebSocketServerService<Application> |
|
|
@ -6,7 +8,20 @@ export default class WebSocketServer extends WebSocketServerService<Application> |
|
|
|
/** |
|
|
|
* The name of the service |
|
|
|
*/ |
|
|
|
public NAME = "WebSocket Server"; |
|
|
|
public readonly NAME = "WebSocket Server"; |
|
|
|
|
|
|
|
/** |
|
|
|
* Reference to the Seeker IPC service |
|
|
|
*/ |
|
|
|
protected seeker!: SeekerIpc; |
|
|
|
|
|
|
|
/** |
|
|
|
* Boot the service |
|
|
|
*/ |
|
|
|
public override async boot() { |
|
|
|
super.boot(); |
|
|
|
this.seeker = this.app.service<SeekerIpc>("Seeker"); |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
* The application key used for authentication |
|
|
@ -16,15 +31,20 @@ export default class WebSocketServer extends WebSocketServerService<Application> |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
* Install the websocket methods |
|
|
|
* Install the websocket request methods |
|
|
|
*/ |
|
|
|
protected override installMethods() { |
|
|
|
this.installMethod("test", this.test.bind(this)); |
|
|
|
this.installMethod(WebSocketMethod.TicketProgress, this.ticketProgress.bind(this)); |
|
|
|
} |
|
|
|
|
|
|
|
protected test() { |
|
|
|
return new Promise<string>(resolve => { |
|
|
|
resolve("This is the response from the server"); |
|
|
|
}); |
|
|
|
// Methods -------------------------------------------------------------------------------------
|
|
|
|
|
|
|
|
/** |
|
|
|
* Get the ticket progress |
|
|
|
*/ |
|
|
|
protected async ticketProgress(ticketIds: number[]) { |
|
|
|
// let result: { [ticketId: number]: { plexLink?: string, progress?: number } } = {};
|
|
|
|
let response = await this.seeker.getMovieTicketStates(ticketIds); |
|
|
|
return response; |
|
|
|
} |
|
|
|
} |