#pragma once // Spec: models.md "Chat websocket". decode: frame bytes -> event, nullopt (frame dropped) on any problem. // encode*: byte compatible with Swift JSONEncoder(): compact, declaration order (type first), "/" escaped as "\/", // non-ASCII raw UTF-8, control characters escaped (\b \f \n \r \t, others \u00XX). #include #include #include #include "model/ChatSocketEvent.hpp" namespace dp { class ChatSocketCodec { public: static std::optional decode(const std::string& frame); static std::string encodeSend(const std::string& receiverUid, const std::string& content, const std::vector& attachmentUids, const std::string& clientId); static std::string encodeTyping(const std::string& receiverUid); static std::string encodeRead(const std::string& withUid); static std::string quote(const std::string& text); // one JSON string literal, Foundation style }; } // namespace dp