mirror of
https://github.com/zigzap/zap.git
synced 2025-10-20 15:14:08 +00:00
0.15.1-fix websockets example
This commit is contained in:
parent
a45baf78ea
commit
8540828bf5
2 changed files with 10 additions and 10 deletions
|
@ -35,7 +35,7 @@ const ContextManager = struct {
|
||||||
.allocator = allocator,
|
.allocator = allocator,
|
||||||
.channel = channelName,
|
.channel = channelName,
|
||||||
.usernamePrefix = usernamePrefix,
|
.usernamePrefix = usernamePrefix,
|
||||||
.contexts = ContextList.init(allocator),
|
.contexts = ContextList.empty,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -43,7 +43,7 @@ const ContextManager = struct {
|
||||||
for (self.contexts.items) |ctx| {
|
for (self.contexts.items) |ctx| {
|
||||||
self.allocator.free(ctx.userName);
|
self.allocator.free(ctx.userName);
|
||||||
}
|
}
|
||||||
self.contexts.deinit();
|
self.contexts.deinit(self.allocator);
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn newContext(self: *ContextManager) !*Context {
|
pub fn newContext(self: *ContextManager) !*Context {
|
||||||
|
@ -73,7 +73,7 @@ const ContextManager = struct {
|
||||||
.context = ctx,
|
.context = ctx,
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
try self.contexts.append(ctx);
|
try self.contexts.append(self.allocator, ctx);
|
||||||
return ctx;
|
return ctx;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
|
@ -63,7 +63,7 @@ pub fn Handler(comptime ContextType: type) type {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn internal_on_message(handle: WsHandle, msg: fio.fio_str_info_s, is_text: u8) callconv(.C) void {
|
fn internal_on_message(handle: WsHandle, msg: fio.fio_str_info_s, is_text: u8) callconv(.c) void {
|
||||||
const user_provided_settings: ?*WebSocketSettings = @as(?*WebSocketSettings, @ptrCast(@alignCast(fio.websocket_udata_get(handle))));
|
const user_provided_settings: ?*WebSocketSettings = @as(?*WebSocketSettings, @ptrCast(@alignCast(fio.websocket_udata_get(handle))));
|
||||||
const message = msg.data[0..msg.len];
|
const message = msg.data[0..msg.len];
|
||||||
if (user_provided_settings) |settings| {
|
if (user_provided_settings) |settings| {
|
||||||
|
@ -75,7 +75,7 @@ pub fn Handler(comptime ContextType: type) type {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn internal_on_open(handle: WsHandle) callconv(.C) void {
|
fn internal_on_open(handle: WsHandle) callconv(.c) void {
|
||||||
const user_provided_settings: ?*WebSocketSettings = @as(?*WebSocketSettings, @ptrCast(@alignCast(fio.websocket_udata_get(handle))));
|
const user_provided_settings: ?*WebSocketSettings = @as(?*WebSocketSettings, @ptrCast(@alignCast(fio.websocket_udata_get(handle))));
|
||||||
if (user_provided_settings) |settings| {
|
if (user_provided_settings) |settings| {
|
||||||
if (settings.on_open) |on_open| {
|
if (settings.on_open) |on_open| {
|
||||||
|
@ -86,7 +86,7 @@ pub fn Handler(comptime ContextType: type) type {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn internal_on_ready(handle: WsHandle) callconv(.C) void {
|
fn internal_on_ready(handle: WsHandle) callconv(.c) void {
|
||||||
const user_provided_settings: ?*WebSocketSettings = @as(?*WebSocketSettings, @ptrCast(@alignCast(fio.websocket_udata_get(handle))));
|
const user_provided_settings: ?*WebSocketSettings = @as(?*WebSocketSettings, @ptrCast(@alignCast(fio.websocket_udata_get(handle))));
|
||||||
if (user_provided_settings) |settings| {
|
if (user_provided_settings) |settings| {
|
||||||
if (settings.on_ready) |on_ready| {
|
if (settings.on_ready) |on_ready| {
|
||||||
|
@ -97,7 +97,7 @@ pub fn Handler(comptime ContextType: type) type {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn internal_on_shutdown(handle: WsHandle) callconv(.C) void {
|
fn internal_on_shutdown(handle: WsHandle) callconv(.c) void {
|
||||||
const user_provided_settings: ?*WebSocketSettings = @as(?*WebSocketSettings, @ptrCast(@alignCast(fio.websocket_udata_get(handle))));
|
const user_provided_settings: ?*WebSocketSettings = @as(?*WebSocketSettings, @ptrCast(@alignCast(fio.websocket_udata_get(handle))));
|
||||||
if (user_provided_settings) |settings| {
|
if (user_provided_settings) |settings| {
|
||||||
if (settings.on_shutdown) |on_shutdown| {
|
if (settings.on_shutdown) |on_shutdown| {
|
||||||
|
@ -108,7 +108,7 @@ pub fn Handler(comptime ContextType: type) type {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn internal_on_close(uuid: isize, udata: ?*anyopaque) callconv(.C) void {
|
fn internal_on_close(uuid: isize, udata: ?*anyopaque) callconv(.c) void {
|
||||||
const user_provided_settings: ?*WebSocketSettings = @as(?*WebSocketSettings, @ptrCast(@alignCast(udata)));
|
const user_provided_settings: ?*WebSocketSettings = @as(?*WebSocketSettings, @ptrCast(@alignCast(udata)));
|
||||||
if (user_provided_settings) |settings| {
|
if (user_provided_settings) |settings| {
|
||||||
if (settings.on_close) |on_close| {
|
if (settings.on_close) |on_close| {
|
||||||
|
@ -219,7 +219,7 @@ pub fn Handler(comptime ContextType: type) type {
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn internal_subscription_on_message(handle: WsHandle, channel: fio.fio_str_info_s, message: fio.fio_str_info_s, udata: ?*anyopaque) callconv(.C) void {
|
pub fn internal_subscription_on_message(handle: WsHandle, channel: fio.fio_str_info_s, message: fio.fio_str_info_s, udata: ?*anyopaque) callconv(.c) void {
|
||||||
if (udata) |p| {
|
if (udata) |p| {
|
||||||
const args = @as(*SubscribeArgs, @ptrCast(@alignCast(p)));
|
const args = @as(*SubscribeArgs, @ptrCast(@alignCast(p)));
|
||||||
if (args.on_message) |on_message| {
|
if (args.on_message) |on_message| {
|
||||||
|
@ -229,7 +229,7 @@ pub fn Handler(comptime ContextType: type) type {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
pub fn internal_subscription_on_unsubscribe(udata: ?*anyopaque) callconv(.C) void {
|
pub fn internal_subscription_on_unsubscribe(udata: ?*anyopaque) callconv(.c) void {
|
||||||
if (udata) |p| {
|
if (udata) |p| {
|
||||||
const args = @as(*SubscribeArgs, @ptrCast(@alignCast(p)));
|
const args = @as(*SubscribeArgs, @ptrCast(@alignCast(p)));
|
||||||
if (args.on_unsubscribe) |on_unsubscribe| {
|
if (args.on_unsubscribe) |on_unsubscribe| {
|
||||||
|
|
Loading…
Add table
Reference in a new issue