Sry.Framework.Web/MessageBody.cs

(开头部分) 2KB

这里只显示每个文件的开头 60 行。登录后可以解锁完整代码。

using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Sry.Framework.Web
{
    public abstract class MessageBody
    {
        public short Command { get; set; }
        public short Source { get; set; }
        public long TimeStamp { get; set; }
        public int Length { get; set; }
        public byte[] Content { get; set; }

        public abstract void GetContent(BinaryReader reader);
        public abstract void SetContent(BinaryWriter writer);


        public MessageBody Parse(System.IO.BinaryReader reader)
        {
            this.Source = reader.ReadInt16();
            this.TimeStamp = reader.ReadInt64();
            this.Length = reader.ReadInt32();
            this.Content = reader.ReadBytes(this.Length);
            if (this.Content != null && this.Content.Length > 0)
            {
                using (Stream stream = new MemoryStream(this.Content))
                {
                    using (BinaryReader contentReader = new BinaryReader(stream))
                    {
                        GetContent(contentReader);
                    }
                }
            }
            return this;
        }

        public abstract Int16 GetCommand();
        public void Write(System.IO.BinaryWriter writer)
        {
            writer.Write(this.GetCommand());
            writer.Write(this.Source);
            writer.Write(this.TimeStamp);


            using (MemoryStream stream = new MemoryStream())
            {
                using (BinaryWriter contentWriter = new BinaryWriter(stream))
                {
                    SetContent(contentWriter);
                    if (stream.Length > 0)
                    {
                        this.Content = stream.ToArray();
                        if (this.Content != null && this.Content.Length > 0)
                            this.Length = this.Content.Length;
                    }
                }
后面还有 9 行代码,购买后查看完整代码

24 小时内免费解锁 3 个项目,之后 1 算力/个。 规则说明

AI 解读 AI

登录后可用,每次 10 算力,解读结果公开显示在下面。

还没有人解读过这个文件。