// 初始化 public NetSocket(ServerTask _serverTaskCtx = null) { serverTask = _serverTaskCtx; unPackCache.buf = null; unPackCache.len = 0; if (serverTask == null) { return; } Server server = serverTask.GetServer(); SetDePacketor(server.dePacketor); unPackHeadLen = dePacketor.GetPackHeadPreLength(); UniqueID uniqueID = UniqueID.GetInstance(); if (server.serverTaskCount > 1) { id = uniqueID.gen_multi(); } else { id = uniqueID.gen(); } }
public void SetDePacketor(DePacketor depacketor) { if (depacketor == dePacketor) { return; } this.dePacketor = depacketor; if (dePacketor != null) { unPackHeadLen = dePacketor.GetPackHeadPreLength(); } RemovePack(); unPackCache.buf = null; unPackCache.len = 0; unPackCalcLen = 0; cachePack = null; cachePackLen = 0; }