A websocket implementation for zig
0

Configure Feed

Select the types of activity you want to include in your feed.

Make testing.init take an option parameter

Allow port to be specified.

https://github.com/karlseguin/websocket.zig/issues/71

```
wt.init(.{.port = 3233});
```

Karl Seguin (Jul 24, 2025, 8:02 AM +0800) fd689480 c14617f9

+6 -3
+1 -1
readme.md
··· 403 403 const wt = @import("websocket").testing; 404 404 405 405 test "handler: echo" { 406 - var wtt = wt.init(); 406 + var wtt = wt.init(.{}); 407 407 defer wtt.deinit(); 408 408 409 409 // create an instance of your handler (however you want)
+5 -2
src/testing.zig
··· 16 16 received: std.ArrayList(ws.Message), 17 17 received_index: usize, 18 18 19 - fn init() Testing { 19 + const Opts = struct { 20 + port: ?u16 = null, 21 + }; 22 + fn init(opts: Opts) Testing { 20 23 const arena = t.allocator.create(std.heap.ArenaAllocator) catch unreachable; 21 24 errdefer t.allocator.destroy(arena); 22 25 ··· 49 52 ._closed = false, 50 53 .started = 0, 51 54 .stream = pair.server, 52 - .address = std.net.Address.parseIp("127.0.0.1", 0) catch unreachable, 55 + .address = std.net.Address.parseIp("127.0.0.1", opts.port orelse 0) catch unreachable, 53 56 }, 54 57 .reader = reader, 55 58 .received = std.ArrayList(ws.Message).init(aa),