summaryrefslogtreecommitdiff
path: root/src/ninep
diff options
context:
space:
mode:
Diffstat (limited to 'src/ninep')
-rw-r--r--src/ninep/events.zig10
1 files changed, 10 insertions, 0 deletions
diff --git a/src/ninep/events.zig b/src/ninep/events.zig
index 7a06bd04..d2beecd1 100644
--- a/src/ninep/events.zig
+++ b/src/ninep/events.zig
@@ -226,6 +226,16 @@ pub fn dropAnnouncement(p: *Pardes, serial: u32, text: []const u8) void {
p.fs.log.buf.shrinkRetainingCapacity(last.at);
}
+/// Drops the newest record when it is a msg saying `text` (of any pane)
+/// that no follower has read: a failure its write's err record will say.
+pub fn dropMessage(p: *Pardes, text: []const u8) void {
+ const last = newest(p) orelse return;
+ if (followerRead(p, last.seq) or !std.mem.startsWith(u8, last.text, "msg ")) return;
+ const rest = last.text["msg ".len..];
+ const sp = std.mem.indexOfScalar(u8, rest, ' ') orelse return;
+ if (std.mem.eql(u8, rest[sp + 1 ..], text)) p.fs.log.buf.shrinkRetainingCapacity(last.at);
+}
+
/// Pushes `record`, or, when it repeats the newest record word for word,
/// counts that one instead: `<record> (x2)`, the count being every time it
/// was said. One a follower has already read is not rewritten: the repeat