Skip to content

Commit 92f1700

Browse files
committed
[cdp] route messages to subframe chobitsu instances
1 parent da9f63f commit 92f1700

File tree

1 file changed

+15
-1
lines changed

1 file changed

+15
-1
lines changed

frontend/src/CDP.ts

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ class CDPServer {
2727
const msg = JSON.parse(message);
2828
const resultMsg: any = {
2929
id: msg.id,
30+
sessionId: msg.sessionId,
3031
};
3132
console.log(msg);
3233

@@ -132,6 +133,17 @@ class CDPServer {
132133
}
133134

134135
if (sessionId) {
136+
console.log("Routing " + method + " to session " + sessionId);
137+
138+
const result: any = await this.callTabMethod(sessionId, method, params);
139+
140+
if (result.result) {
141+
return result.result;
142+
} else if (result.error) {
143+
throw new Error(result.error.message);
144+
} else {
145+
throw new Error("Bad message from subcdp");
146+
}
135147
}
136148

137149
throw Error(`${method} unimplemented`);
@@ -194,8 +206,10 @@ const Scopes = {
194206
};
195207
},
196208

197-
setAutoAttach(params: Protocol.Target.SetAutoAttachRequest) {
209+
async setAutoAttach(params: Protocol.Target.SetAutoAttachRequest) {
198210
console.log("Target.setAutoAttach", params);
211+
212+
return {};
199213
},
200214
getTargetInfo(
201215
params: Protocol.Target.GetTargetInfoRequest

0 commit comments

Comments
 (0)