From fcb3090055429a108b9837dbd4ba505d9c291129 Mon Sep 17 00:00:00 2001 From: Sadie Powell Date: Wed, 11 Mar 2026 21:54:40 +0000 Subject: Rework sending server protocol messages. - Replace CmdBuilder with MessageBuilder. This has a less footgun API. All message building has to go through this now so we can implement other message formats in the future. - Replace the message parsing in WriteLine with an analogue to PreProcessOldProtocolMessage. This should be much faster. - Move parameter translation from the core to spanningtree. - Change EncodeParameter to return the value instead of updating in place. - Replace the OnBuild*Message events with one OnServerMessage that can now access all parts of the message and change them. --- modules/spanningtree/metadata.cpp | 30 +++++++++++++++--------------- 1 file changed, 15 insertions(+), 15 deletions(-) (limited to 'modules/spanningtree/metadata.cpp') diff --git a/modules/spanningtree/metadata.cpp b/modules/spanningtree/metadata.cpp index 1b0814344..080768a63 100644 --- a/modules/spanningtree/metadata.cpp +++ b/modules/spanningtree/metadata.cpp @@ -112,44 +112,44 @@ CmdResult CommandMetadata::Handle(User* srcuser, Params& params) } CommandMetadata::Builder::Builder(const Extensible* ext, const std::string& key, const std::string& val) - : CmdBuilder("METADATA") + : MessageBuilder("METADATA") { switch (ext->extype) { case ExtensionType::CHANNEL: { const Channel* chan = static_cast(ext); - push(chan->name); - push_int(chan->age); + Push(chan->name); + Push(chan->age); break; } case ExtensionType::MEMBERSHIP: { const Membership* memb = static_cast(ext); - push_raw("@"); - push(memb->user->uuid); - push_raw(memb->chan->name); - push_int(memb->chan->age); - push_int(memb->id); + Push("@"); + Push(memb->user->uuid); + Push(memb->chan->name); + Push(memb->chan->age); + Push(memb->id); break; } case ExtensionType::USER: { const User* user = static_cast(ext); - push(user->uuid); + Push(user->uuid); break; } } - push(key); - push_last(val); + Push(key); + Push(val); } CommandMetadata::Builder::Builder(const std::string& key, const std::string& val) - : CmdBuilder("METADATA") + : MessageBuilder("METADATA") { - push("*"); - push(key); - push_last(val); + Push("*"); + Push(key); + Push(val); } -- cgit v1.3.1-10-gc9f91