public void Delete(long id) { long offset = SeekDataOffset(id); if (offset < 0) { return; } byte[] head = new byte[4 + 4 + 9]; // size + tag + id int headLen = data.Read(head, 0, head.Length); if (headLen == 0) // eof { return; } global::Zeze.Serialize.ByteBuffer bb = global::Zeze.Serialize.ByteBuffer.Wrap(head, 0, headLen); int msgsize = bb.ReadInt4(); int tag = bb.ReadInt4(); long existid = bb.ReadLong(); if (existid != id) { throw new Exception("msgId error"); // report or ignore } tag |= ChatHistoryMessage.TagDeleted; byte[] newtagBytes = BitConverter.GetBytes(tag); long tagoffset = offset + 4; if (tagoffset != data.Seek(tagoffset, System.IO.SeekOrigin.Begin)) { throw new Exception("seek error"); } data.Write(newtagBytes, 0, 4); }
public void Decode(global::Zeze.Serialize.ByteBuffer bb) { this.Tag = bb.ReadInt4(); this.Id = bb.ReadLong(); this.TimeTicks = bb.ReadLong(); this.Sender = bb.ReadString(); this.Type = bb.ReadInt(); this.Content = bb.ReadBytes(); int propertiesSize = bb.ReadInt(); for (int i = 0; i < propertiesSize; ++i) { int key = bb.ReadInt(); byte[] value = bb.ReadBytes(); Properties.Add(key, value); } }