diff --git a/src/network/protocols.zig b/src/network/protocols.zig index a0b3373700..2d9ebc6ddf 100644 --- a/src/network/protocols.zig +++ b/src/network/protocols.zig @@ -47,6 +47,12 @@ pub fn init() void { // MARK: init() pub fn onReceive(conn: *Connection, protocolIndex: u8, data: []const u8) !void { // MARK: onReceive() if (conn.handShakeState.raw != .complete and protocolIndex != handshake.id) return error.HandshakeIncomplete; + const oldContext = main.sync.threadContext; + defer main.sync.threadContext = oldContext; + main.sync.threadContext = switch (conn.isServerSide()) { + true => .server, + false => .client, + }; const protocolReceive = blk: { if (conn.isServerSide()) break :blk serverReceiveList[protocolIndex] orelse return error.Invalid; break :blk clientReceiveList[protocolIndex] orelse return error.Invalid;