diff --git a/demo/src/app/views/websockets.zig b/demo/src/app/views/websockets.zig index a823d4f..097d427 100644 --- a/demo/src/app/views/websockets.zig +++ b/demo/src/app/views/websockets.zig @@ -9,6 +9,12 @@ pub fn index(request: *jetzig.Request) !jetzig.View { return request.render(.ok); } +pub fn get(id: []const u8, request: *jetzig.Request) !jetzig.View { + var root = try request.data(.object); + try root.put("join_token", id); + return request.renderTemplate("websockets/index", .ok); +} + pub const Channel = struct { pub fn open(channel: jetzig.channels.Channel) !void { var state = try channel.state("game"); @@ -17,8 +23,8 @@ pub const Channel = struct { } pub const Actions = struct { - pub fn join(channel: jetzig.channels.Channel, token: []const u8) !void { - try channel.connect("game", token); + pub fn join(channel: jetzig.channels.Channel, join_token: []const u8) !void { + try channel.connect("game", join_token); } pub fn move(channel: jetzig.channels.Channel, cell: usize) !void { diff --git a/demo/src/app/views/websockets/index.zmpl b/demo/src/app/views/websockets/index.zmpl index 07b8b4f..3adee66 100644 --- a/demo/src/app/views/websockets/index.zmpl +++ b/demo/src/app/views/websockets/index.zmpl @@ -3,6 +3,10 @@
+@if ($.join_token) |join_token| + Join Game +@end +