Mercurial > hg > ugly-duckling
comparison src/app/services/feature-extraction/FeatureExtractionWorker.ts @ 62:2171dd56756c
Use VampTestPlugin for now. Also set up Collect method calls for the worker. Currently use the same stream for both process and collect extraction.
author | Lucas Thompson <dev@lucas.im> |
---|---|
date | Fri, 09 Dec 2016 14:06:04 +0000 |
parents | 933c64ebcd13 |
children | 270f59ef3b83 |
comparison
equal
deleted
inserted
replaced
61:8b8f794942d1 | 62:2171dd56756c |
---|---|
3 */ | 3 */ |
4 | 4 |
5 import {ListResponse, EmscriptenProxy} from 'piper'; | 5 import {ListResponse, EmscriptenProxy} from 'piper'; |
6 import {PiperSimpleClient} from 'piper/HigherLevelUtilities'; | 6 import {PiperSimpleClient} from 'piper/HigherLevelUtilities'; |
7 import { VampExamplePlugins } from 'piper/ext/VampExamplePluginsModule'; | 7 import { VampExamplePlugins } from 'piper/ext/VampExamplePluginsModule'; |
8 import { VampTestPlugin } from 'piper/ext/VampTestPluginModule'; | |
8 | 9 |
9 | 10 |
10 // TODO TypeScript has a .d.ts file for webworkers, but for some reason it clashes with the typings for dom and causes compiler errors | 11 // TODO TypeScript has a .d.ts file for webworkers, but for some reason it clashes with the typings for dom and causes compiler errors |
11 interface WorkerGlobalScope { | 12 interface WorkerGlobalScope { |
12 onmessage: (this: this, ev: MessageEvent) => any; | 13 onmessage: (this: this, ev: MessageEvent) => any; |
21 private workerScope: WorkerGlobalScope; | 22 private workerScope: WorkerGlobalScope; |
22 private piperClient: PiperSimpleClient; | 23 private piperClient: PiperSimpleClient; |
23 | 24 |
24 constructor(workerScope: WorkerGlobalScope) { | 25 constructor(workerScope: WorkerGlobalScope) { |
25 this.workerScope = workerScope; | 26 this.workerScope = workerScope; |
26 this.piperClient = new PiperSimpleClient(new EmscriptenProxy(VampExamplePlugins())); | 27 this.piperClient = new PiperSimpleClient(new EmscriptenProxy(VampTestPlugin())); |
27 this.workerScope.onmessage = (ev: MessageEvent) => { | 28 this.workerScope.onmessage = (ev: MessageEvent) => { |
28 const sendResponse = (result) => this.workerScope.postMessage({ | 29 const sendResponse = (result) => this.workerScope.postMessage({ |
29 method: ev.data.method, | 30 method: ev.data.method, |
30 result: result | 31 result: result |
31 }); | 32 }); |
33 case 'list': | 34 case 'list': |
34 this.piperClient.list({}).then(sendResponse); | 35 this.piperClient.list({}).then(sendResponse); |
35 break; | 36 break; |
36 case 'process': | 37 case 'process': |
37 this.piperClient.process(ev.data.params).then(sendResponse); | 38 this.piperClient.process(ev.data.params).then(sendResponse); |
39 break; | |
40 case 'collect': | |
41 this.piperClient.collect(ev.data.params).then(sendResponse); | |
38 } | 42 } |
39 }; | 43 }; |
40 } | 44 } |
41 | 45 |
42 } | 46 } |