底層通訊訊息類,定義訊息id、訊息體,和初始化
1using
system; 23
///4
///底層通訊訊息
5/// 6
public
class
tsocketmessage : idisposable 7
2223
public
void
dispose()
24
2829
protected
virtual
void dispose(bool
flag1)
30
32}
33 }
訊息解析器,封裝包頭、包體、解析包
1using
system;
2using
system.collections.generic;
3using
system.io;
4using
system.text; 56
//訊息解析器
7public
class
marshalendian 8
2627
protected
virtual
void dispose(bool
flag1)
28
33 idisposable disposable = this._lbuff as
idisposable;
34if (disposable != null
)
35}
36}
3738
public
byte
encode(tsocketmessage msg)
39
56else
57#endregion
5859
bw.close();
60ms.close();
61bw.dispose();
62ms.dispose();
63return
ms.toarray();
64}
6566
len)
67
8081 listlist = new list();
82 memorystream ms = new
memorystream(buff);
83 binaryreader buffers = new binaryreader(ms, this
.utf8);
84try
85
98 int16 tt1 =buffers.readint16();
99 int16 tt2 =buffers.readint16();
100if (!(tt1 == t1 && tt2 ==t2))
101
105#endregion
106107
#region 包協議
108int offset =buffers.readint32();
109#endregion
110111
#region 包解析
112//
剩餘位元組數大於本次需要讀取的位元組數
113if (offset <= (buffers.basestream.length -buffers.basestream.position))
114
122}
123else
124
129#endregion
130}
131catch
(exception ex)
132finally
133
135buffers.close();
136if (buffers != null
)
137ms.close();
138if (ms != null
)
139}
140return
list;
141}
142 }
自定義結構體封裝
使用nsvalue如下方法進行裝箱 nsvalue valuewithbytes const void value objctype const char type 呼叫下面的方法進行拆箱 void getvalue void value main.m foundationframework cre...
自定義 如何自定義協議
何為自定義協議,其實是相對標準協議來說的,這裡主要針對的是應用層協議 常見的標準的應用層協議如http ftp smtp等,如果我們在網路通訊的過程中不去使用這些標準協議,那就需要自定義協議,比如我們常用的rpc框架 dubbo,thrift 分布式快取 redis,memcached 等都是自定義...
自定義封裝axios
今天研究了一下公司pc端封裝的axios,主要配合element以及js cookie,自己跟著搞了一遍,在這裡記錄一下。import axios from axios import from element ui import cookies from js cokie 基於axios基本配置建立...