Esempio n. 1
0
        /// <inheritdoc/>
        public SerializedMessageData Serialize(IWolfMessage message)
        {
            JObject      payload = message.SerializeJsonPayload();
            JObject      body    = payload["body"] as JObject;
            IChatMessage msg     = (IChatMessage)message;

            // metadata props
            JObject metadata = new JObject();

            SerializationHelper.MovePropertyIfExists(ref body, ref metadata, "isDeleted");
            SerializationHelper.MovePropertyIfExists(ref body, ref metadata, "isTipped");
            if (metadata.HasValues)
            {
                body.Add(new JProperty("metadata", metadata));
            }

            // raw data
            if (msg.RawData?.Any() == true)
            {
                body["data"] = new JObject(new JProperty("_placeholder", true), new JProperty("num", 0));
                return(new SerializedMessageData(payload, msg.RawData.ToArray()));
            }
            return(new SerializedMessageData(payload));
        }
Esempio n. 2
0
 /// <inheritdoc/>
 public virtual SerializedMessageData Serialize(IWolfMessage message)
 => new SerializedMessageData(message.SerializeJsonPayload(SerializationHelper.DefaultSerializer));