summaryrefslogtreecommitdiff
path: root/src/detached/wire.zig
diff options
context:
space:
mode:
Diffstat (limited to 'src/detached/wire.zig')
-rw-r--r--src/detached/wire.zig6
1 files changed, 4 insertions, 2 deletions
diff --git a/src/detached/wire.zig b/src/detached/wire.zig
index 347d45d1..78f6e76e 100644
--- a/src/detached/wire.zig
+++ b/src/detached/wire.zig
@@ -134,7 +134,7 @@ pub const ServerMsg = union(ServerTag) {
/// Who the client is now (its id and view in the session), how long the
/// dump that follows is, and the session's offset from UTC (a replica
/// guesses the session's time of day).
- welcome: struct { pid: u32, session: []const u8, client: u16 = 0, view: u8 = 0, dump_len: u64 = 0, gmtoff: i32 = 0, digest: u64 = 0 },
+ welcome: struct { pid: u32, session: []const u8, client: u16 = 0, view: u8 = 0, dump_len: u64 = 0, gmtoff: i32 = 0, digest: u64 = 0, semantics: u64 = 0 },
refused: []const u8,
pong: u64,
dump: []const u8,
@@ -164,6 +164,7 @@ pub fn decodeServer(tag: u8, payload: []const u8) Error!ServerMsg {
.dump_len = try r.takeInt(u64, .little),
.gmtoff = try r.takeInt(i32, .little),
.digest = try r.takeInt(u64, .little),
+ .semantics = try r.takeInt(u64, .little),
} },
.refused => .{ .refused = try r.take(try r.takeInt(u16, .little)) },
.pong => .{ .pong = try r.takeInt(u64, .little) },
@@ -188,6 +189,7 @@ pub fn encodeServer(out: []u8, msg: ServerMsg) Error![]const u8 {
try w.writeInt(u64, h.dump_len, .little);
try w.writeInt(i32, h.gmtoff, .little);
try w.writeInt(u64, h.digest, .little);
+ try w.writeInt(u64, h.semantics, .little);
},
.refused => |words| try putSlice16(&w, words),
.pong => |v| try w.writeInt(u64, v, .little),
@@ -620,7 +622,7 @@ test "detached wire: every Event variant round-trips" {
const bytes = try encodeServer(&buf, .{ .welcome = .{ .pid = 42, .session = "work" } });
const f = (try framed(bytes)).?;
try testing.expectEqual(@as(u8, 0x01), f.tag);
- try testing.expectEqualSlices(u8, &.{ 42, 0, 0, 0, 4, 0, 'w', 'o', 'r', 'k', 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }, f.payload);
+ try testing.expectEqualSlices(u8, &.{ 42, 0, 0, 0, 4, 0, 'w', 'o', 'r', 'k', 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }, f.payload);
const back = (try decodeServer(f.tag, f.payload)).welcome;
try testing.expectEqualStrings("work", back.session);
try testing.expectEqual(@as(u32, 42), back.pid);