初始化版本

This commit is contained in:
LL
2025-11-14 16:12:32 +08:00
commit ea40f18aa6
326 changed files with 137063 additions and 0 deletions

View File

@@ -0,0 +1,65 @@
using System;
namespace NetWorkHelper
{
/// <summary>
/// 消息单元类(可序列化)
/// </summary>
[Serializable]
public class MsgCell : IDataCell
{
/// <summary>
/// 消息标识
/// </summary>
public int MessageId { get; set; }
private object _data;
/// <summary>
/// 消息序列化数据
/// </summary>
public object Data
{
get { return _data; }
set { _data = value; }
}
#region
public MsgCell() { }
/// <summary>
/// 构造函数
/// </summary>
/// <param name="messageId">消息标识</param>
/// <param name="data">序列化数据</param>
public MsgCell(
int messageId,
object data)
{
MessageId = messageId;
_data = data;
}
#endregion
/// <summary>
/// 将数据序列化成Byte[]数组
/// </summary>
/// <returns></returns>
public byte[] ToBuffer()
{
byte[] data = SerHelper.Serialize(_data);
byte[] id = BitConverter.GetBytes(MessageId);
byte[] buffer = new byte[data.Length + id.Length];
Buffer.BlockCopy(id, 0, buffer, 0, id.Length);
Buffer.BlockCopy(data, 0, buffer, id.Length, data.Length);
return buffer;
}
/// <summary>
/// 将Byte[]数组反序列化成数据结构
/// </summary>
/// <param name="buffer"></param>
public void FromBuffer(byte[] buffer)
{
MessageId = BitConverter.ToInt32(buffer, 0);
_data = SerHelper.Deserialize(buffer, 4);
}
}
}

View File

@@ -0,0 +1,39 @@
using System;
namespace NetWorkHelper
{
[Serializable]
public class MsgTypeCell
{
private MsgType _msgType;
private string _imageSuffix = "";
private byte[] _bufferBytes;
/// <summary>
/// 消息类型
/// </summary>
public MsgType Msgtype
{
get { return _msgType; }
set { _msgType = value; }
}
/// <summary>
/// 图片后缀格式
/// </summary>
public string ImageSuffix
{
get { return _imageSuffix; }
set { _imageSuffix = value; }
}
public byte[] BufferBytes
{
get { return _bufferBytes; }
set { _bufferBytes = value; }
}
public MsgTypeCell(MsgType msgType, byte[] buffer)
{
Msgtype = msgType;
BufferBytes = buffer;
}
}
}

View File

@@ -0,0 +1,39 @@
using System;
namespace NetWorkHelper
{
[Serializable]
public class ResponeTraFransfersFile
{
private string _md5;
private int _size;
private int _index;
public ResponeTraFransfersFile() { }
public ResponeTraFransfersFile(string md5, int size, int index)
{
_md5 = md5;
_size = size;
_index = index;
}
public string MD5
{
get { return _md5; }
set { _md5 = value; }
}
public int Size
{
get { return _size; }
set { _size = value; }
}
public int Index
{
get { return _index; }
set { _index = value; }
}
}
}