mirror of
https://github.com/lightpanda-io/browser.git
synced 2025-10-29 07:03:29 +00:00
Simplify browser session.setInspector
Signed-off-by: Francis Bouvier <francis@lightpanda.io>
This commit is contained in:
@@ -140,11 +140,12 @@ pub const Session = struct {
|
|||||||
|
|
||||||
pub fn setInspector(
|
pub fn setInspector(
|
||||||
self: *Session,
|
self: *Session,
|
||||||
ctx: *anyopaque,
|
ctx: anytype,
|
||||||
onResp: jsruntime.InspectorOnResponseFn,
|
onResp: jsruntime.InspectorOnResponseFn,
|
||||||
onEvent: jsruntime.InspectorOnEventFn,
|
onEvent: jsruntime.InspectorOnEventFn,
|
||||||
) !void {
|
) !void {
|
||||||
self.inspector = try jsruntime.Inspector.init(self.alloc, self.env, ctx, onResp, onEvent);
|
const ctx_opaque = @as(*anyopaque, @ptrCast(ctx));
|
||||||
|
self.inspector = try jsruntime.Inspector.init(self.alloc, self.env, ctx_opaque, onResp, onEvent);
|
||||||
self.env.setInspector(self.inspector.?);
|
self.env.setInspector(self.inspector.?);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -245,8 +245,7 @@ pub const Ctx = struct {
|
|||||||
|
|
||||||
fn newSession(self: *Ctx) !void {
|
fn newSession(self: *Ctx) !void {
|
||||||
try self.browser.newSession(self.alloc(), self.loop);
|
try self.browser.newSession(self.alloc(), self.loop);
|
||||||
const ctx_opaque = @as(*anyopaque, @ptrCast(self));
|
try self.browser.currentSession().setInspector(self, Ctx.onInspectorResp, Ctx.onInspectorNotif);
|
||||||
try self.browser.currentSession().setInspector(ctx_opaque, Ctx.onInspectorResp, Ctx.onInspectorNotif);
|
|
||||||
self.sessionNew = true;
|
self.sessionNew = true;
|
||||||
std.log.debug("new session", .{});
|
std.log.debug("new session", .{});
|
||||||
}
|
}
|
||||||
@@ -380,8 +379,7 @@ pub fn listen(browser: *Browser, loop: *public.Loop, server_socket: std.posix.so
|
|||||||
.conn_completion = &conn_completion,
|
.conn_completion = &conn_completion,
|
||||||
.timeout_completion = &timeout_completion,
|
.timeout_completion = &timeout_completion,
|
||||||
};
|
};
|
||||||
const ctx_opaque = @as(*anyopaque, @ptrCast(ctx));
|
try browser.currentSession().setInspector(&ctx, Ctx.onInspectorResp, Ctx.onInspectorNotif);
|
||||||
try browser.currentSession().setInspector(ctx_opaque, Ctx.onInspectorResp, Ctx.onInspectorNotif);
|
|
||||||
|
|
||||||
// accepting connection asynchronously on internal server
|
// accepting connection asynchronously on internal server
|
||||||
std.log.debug("accepting new conn...", .{});
|
std.log.debug("accepting new conn...", .{});
|
||||||
|
|||||||
Reference in New Issue
Block a user