Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
],
"name": "@ofs-users/plugin",
"type": "module",
"version": "1.5.0",
"version": "1.5.2",
"description": "Oracle Field Service plugin base code",
"main": "dist/ofs-plugin.es.js",
"module": "dist/ofs-plugin.es.js",
Expand Down
28 changes: 11 additions & 17 deletions src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -100,17 +100,19 @@ export abstract class OFSPlugin {
* @returns
*/
private async _getWebMessage(message: MessageEvent): Promise<boolean> {
console.log(`${this._tag}: Message received:`, message.data);
console.log(`${this._tag}: Coming from ${message.origin}`);
// Validate that it is a valid OFS message
var parsed_message = OFSMessage.parse(message.data);
console.log(`${this._tag}: Message received - method: ${parsed_message.method}`);
console.log(`${this._tag}: Coming from ${message.origin}`);

switch (parsed_message.method) {
case "init":
console.debug(`${this._tag}: Processing init message`);
this._storeInitData(parsed_message as OFSInitMessage);
this._init(parsed_message);
break;
case "open":
console.debug(`${this._tag}: Processing open message`);
globalThis.waitForProxy = false;
this._createProxy(parsed_message);
var iteration: number = 0;
Expand All @@ -131,17 +133,21 @@ export abstract class OFSPlugin {
this.open(parsed_message as OFSOpenMessage);
break;
case "updateResult":
console.debug(`${this._tag}: Processing updateResult message`);
this.updateResult(parsed_message);
break;
case "callProcedureResult":
console.debug(`${this._tag}: Processing callProcedureResult - callId: ${(parsed_message as OFSCallProcedureResultMessage).callId}`);
this._callProcedureResult(
parsed_message as OFSCallProcedureResultMessage
);
break;
case "wakeup":
console.debug(`${this._tag}: Processing wakeup message`);
this.wakeup(parsed_message);
break;
case "error":
console.debug(`${this._tag}: Processing error message`);
this.error(parsed_message);
break;
case "no method":
Expand Down Expand Up @@ -197,11 +203,7 @@ export abstract class OFSPlugin {
},
};
console.debug(
`${
this.tag
}. I will request the Token forthe application ${applicationKey} with this message ${JSON.stringify(
callProcedureData
)}`
`${this.tag}. Requesting token for application ${applicationKey}`
);
this.callProcedure(callProcedureData);
globalThis.waitForProxy = true;
Expand Down Expand Up @@ -389,23 +391,15 @@ export abstract class OFSPlugin {
token: parsed_message.resultData.token,
};
console.debug(
`${
this.tag
}. I will create the proxy with this data ${JSON.stringify(
OFSCredentials
)}`
`${this.tag}. Creating proxy with provided credentials`
);
this._proxy = new OFS(OFSCredentials);
globalThis.waitForProxy = false;
return;
}
} else {
console.error(
`${
this.tag
}. Problems processing the Token Response ${JSON.stringify(
parsed_message
)}`
`${this.tag}. Problems processing the Token Response - missing resultData`
);
}
} else {
Expand Down