MCPcopy Index your code
hub / github.com/jabbany/CommentCoreLibrary / constructor

Method constructor

src/scripting/host/OOAPIWorker.ts:29–55  ·  view source on GitHub ↗
(worker:Worker)

Source from the content-addressed store, hash-verified

27 private _channels:{[channelName:string] : ChannelListener[]} = {};
28
29 constructor(worker:Worker) {
30 this._worker = worker;
31 worker.addEventListener('message', ((e:MessageEvent) => {
32 var message;
33 try {
34 message = JSON.parse(e.data);
35 } catch (e) {
36 this._handleMalformed(e);
37 return;
38 }
39
40 if (!(typeof message === 'object') || message === null) {
41 this._handleMalformed(new WorkerMessageError(message));
42 return;
43 }
44 if (!('channel' in message) || !('payload' in message) ||
45 (typeof message['channel'] !== 'string')) {
46
47 this._handleMalformed(new WorkerMessageError(message));
48 return;
49 }
50
51 var apiMessage:OOAPIMessage = <OOAPIMessage> message;
52 this._dispatchEvent(apiMessage.channel, message);
53
54 }).bind(this));
55 }
56
57 private _handleMalformed(error:Error):void {
58 if (typeof this._malformedHandler === 'function') {

Callers

nothing calls this directly

Calls 4

_handleMalformedMethod · 0.95
_dispatchEventMethod · 0.95
bindMethod · 0.80
addEventListenerMethod · 0.65

Tested by

no test coverage detected