Browse Source

Add progress handling to request service

dev
David Ludwig 4 years ago
parent
commit
a0d750442f
3 changed files with 27 additions and 9 deletions
  1. +0
    -1
      services/request/src/services/MovieSearch.ts
  2. +27
    -7
      services/request/src/services/WebSocketServer.ts
  3. +0
    -1
      services/request/tsconfig.json

+ 0
- 1
services/request/src/services/MovieSearch.ts View File

@ -66,7 +66,6 @@ export default class MovieSearch extends InternalService<Application>
* Search for a movie
*/
public async search(query: string, year?: number) {
this.log("Searching for John Wick...");
let [ movies, ticketMap ] = await Promise.all([
this.searchIpc.searchMovie(query, year),
MovieTicket.activeTicketMap()


+ 27
- 7
services/request/src/services/WebSocketServer.ts View File

@ -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;
}
}

+ 0
- 1
services/request/tsconfig.json View File

@ -1,7 +1,6 @@
{
"extends": "../../tsconfig.json",
"compilerOptions": {
"target": "es2015",
"baseUrl": "./src", /* Base directory to resolve non-absolute module names. */
"sourceMap": true, /* Generates corresponding '.map' file. */
"outDir": "./dist", /* Redirect output structure to the directory. */


Loading…
Cancel
Save