mirror of
https://github.com/lightpanda-io/browser.git
synced 2025-10-30 15:41:48 +00:00
Working sendLater (I/O timeout)
Signed-off-by: Francis Bouvier <francis@lightpanda.io>
This commit is contained in:
@@ -17,13 +17,12 @@ pub fn browser(
|
||||
action: []const u8,
|
||||
scanner: *std.json.Scanner,
|
||||
ctx: *Ctx,
|
||||
comptime sendFn: SendFn,
|
||||
) ![]const u8 {
|
||||
const method = std.meta.stringToEnum(BrowserMethods, action) orelse
|
||||
return error.UnknownBrowserMethod;
|
||||
return switch (method) {
|
||||
.getVersion => browserGetVersion(alloc, id, scanner, ctx, sendFn),
|
||||
.setDownloadBehavior => browserSetDownloadBehavior(alloc, id, scanner, ctx, sendFn),
|
||||
.getVersion => browserGetVersion(alloc, id, scanner, ctx),
|
||||
.setDownloadBehavior => browserSetDownloadBehavior(alloc, id, scanner, ctx),
|
||||
};
|
||||
}
|
||||
|
||||
@@ -38,7 +37,6 @@ fn browserGetVersion(
|
||||
id: u64,
|
||||
_: *std.json.Scanner,
|
||||
_: *Ctx,
|
||||
comptime _: SendFn,
|
||||
) ![]const u8 {
|
||||
const Res = struct {
|
||||
protocolVersion: []const u8,
|
||||
@@ -63,7 +61,6 @@ fn browserSetDownloadBehavior(
|
||||
id: u64,
|
||||
scanner: *std.json.Scanner,
|
||||
_: *Ctx,
|
||||
comptime _: SendFn,
|
||||
) ![]const u8 {
|
||||
const Params = struct {
|
||||
behavior: []const u8,
|
||||
|
||||
@@ -16,7 +16,6 @@ pub fn do(
|
||||
alloc: std.mem.Allocator,
|
||||
s: []const u8,
|
||||
ctx: *Ctx,
|
||||
comptime sendFn: SendFn,
|
||||
) ![]const u8 {
|
||||
var scanner = std.json.Scanner.initCompleteInput(alloc, s);
|
||||
defer scanner.deinit();
|
||||
@@ -29,15 +28,15 @@ pub fn do(
|
||||
try checkKey("method", (try scanner.next()).string);
|
||||
const method = (try scanner.next()).string;
|
||||
|
||||
std.log.debug("cmd: id {any}, method {s}\n", .{ id, method });
|
||||
std.log.debug("cmd: id {any}, method {s}", .{ id, method });
|
||||
|
||||
var iter = std.mem.splitScalar(u8, method, '.');
|
||||
const domain = std.meta.stringToEnum(Domains, iter.first()) orelse
|
||||
return error.UnknonwDomain;
|
||||
|
||||
return switch (domain) {
|
||||
.Browser => browser(alloc, id, iter.next().?, &scanner, ctx, sendFn),
|
||||
.Target => target(alloc, id, iter.next().?, &scanner, ctx, sendFn),
|
||||
.Browser => browser(alloc, id, iter.next().?, &scanner, ctx),
|
||||
.Target => target(alloc, id, iter.next().?, &scanner, ctx),
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
@@ -18,12 +18,11 @@ pub fn target(
|
||||
action: []const u8,
|
||||
scanner: *std.json.Scanner,
|
||||
ctx: *Ctx,
|
||||
comptime sendFn: SendFn,
|
||||
) ![]const u8 {
|
||||
const method = std.meta.stringToEnum(TargetMethods, action) orelse
|
||||
return error.UnknownTargetMethod;
|
||||
return switch (method) {
|
||||
.setAutoAttach => tagetSetAutoAttach(alloc, id, scanner, ctx, sendFn),
|
||||
.setAutoAttach => tagetSetAutoAttach(alloc, id, scanner, ctx),
|
||||
// .getTargetInfo => tagetGetTargetInfo(alloc, id, scanner),
|
||||
};
|
||||
}
|
||||
@@ -33,7 +32,6 @@ fn tagetSetAutoAttach(
|
||||
id: u64,
|
||||
scanner: *std.json.Scanner,
|
||||
_: *Ctx,
|
||||
comptime _: SendFn,
|
||||
) ![]const u8 {
|
||||
const Params = struct {
|
||||
autoAttach: bool,
|
||||
@@ -52,7 +50,6 @@ fn tagetGetTargetInfo(
|
||||
id: u64,
|
||||
scanner: *std.json.Scanner,
|
||||
_: *Ctx,
|
||||
comptime _: SendFn,
|
||||
) ![]const u8 {
|
||||
_ = scanner;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user