diff --git a/src/browser/browser.zig b/src/browser/browser.zig index 8c13d63e..5649638d 100644 --- a/src/browser/browser.zig +++ b/src/browser/browser.zig @@ -140,11 +140,12 @@ pub const Session = struct { pub fn setInspector( self: *Session, - ctx: *anyopaque, + ctx: anytype, onResp: jsruntime.InspectorOnResponseFn, onEvent: jsruntime.InspectorOnEventFn, ) !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.?); } diff --git a/src/server.zig b/src/server.zig index bbe41d3f..22b9f9d9 100644 --- a/src/server.zig +++ b/src/server.zig @@ -245,8 +245,7 @@ pub const Ctx = struct { fn newSession(self: *Ctx) !void { try self.browser.newSession(self.alloc(), self.loop); - const ctx_opaque = @as(*anyopaque, @ptrCast(self)); - try self.browser.currentSession().setInspector(ctx_opaque, Ctx.onInspectorResp, Ctx.onInspectorNotif); + try self.browser.currentSession().setInspector(self, Ctx.onInspectorResp, Ctx.onInspectorNotif); self.sessionNew = true; 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, .timeout_completion = &timeout_completion, }; - const ctx_opaque = @as(*anyopaque, @ptrCast(ctx)); - try browser.currentSession().setInspector(ctx_opaque, Ctx.onInspectorResp, Ctx.onInspectorNotif); + try browser.currentSession().setInspector(&ctx, Ctx.onInspectorResp, Ctx.onInspectorNotif); // accepting connection asynchronously on internal server std.log.debug("accepting new conn...", .{});