Skip to content

Commit e4507a5

Browse files
committed
fix: Handle functionResponse
1 parent b25ba6e commit e4507a5

File tree

2 files changed

+12
-2
lines changed

2 files changed

+12
-2
lines changed

src/gotham-node.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { Protocol, Dependency, FnArgs } from "./protocol/protocol";
22
import { GothamConnection, SocketConnection } from './protocol/GothamConnection';
33

4-
export class GothamModule {
4+
export default class GothamModule {
55
protocol: Protocol
66
constructor(connection: GothamConnection) {
77
this.protocol = new Protocol(connection);

src/protocol/protocol.ts

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -194,6 +194,8 @@ export class Protocol {
194194
res = true;
195195
} else if (obj.type === constants.responseType.hookTriggered) {
196196
res = await this.parseHookTriggered(obj as TriggerHookRequest);
197+
} else if (obj.type === constants.responseType.functionResponse) {
198+
res = await this.parseFunctionResponse(obj as FunctionCallResponse);
197199
} else {
198200
res = false;
199201
}
@@ -214,11 +216,19 @@ export class Protocol {
214216
this.sendRequest({
215217
requestId: obj.requestId,
216218
type: 'functionResponse',
217-
data: res
219+
data: res || {}
218220
});
221+
return true;
222+
} else {
223+
// Function wasn't found in the module.
224+
return false;
219225
}
220226
}
221227

228+
async parseFunctionResponse(obj: FunctionCallResponse) {
229+
return obj.data;
230+
}
231+
222232
async parseHookTriggered(obj: TriggerHookRequest) {
223233
if (obj.hook) {
224234
// Hook triggered by another module.

0 commit comments

Comments
 (0)