string localIP; // 本机IP地址 public Server() { serverTaskMgr = new ServerTaskMgr(this); dePacketor = new DePacketor(); SetUseSingleSendTaskProcesser(useSingleSendTaskProcesser); UniqueID.GetInstance(); }
public DePacketor CreateDePacketor() { DePacketor httpDePacketor = new DePacketor(); httpDePacketor.SetPackHeadPreLength(0); httpDePacketor.SetPackTailLength(0); httpDePacketor.SetGetPackDataLengthCallBack(GetHttpPackDataLength); httpDePacketor.SetMsgProcesser(this); return(httpDePacketor); }
void Init(TaskProcesser taskProcesser) { httpMsgProcesser = new HttpMsgProcesser(this); httpDePacketor = httpMsgProcesser.CreateDePacketor(); gamepackMsgProcesser = new GamePackMsgProcesser(this); gamepackDePacketor = gamepackMsgProcesser.CreateDePacketor(); server = new Server(); server.SetServerTaskProcess(-1, taskProcesser); server.SetListenPort(listenPort); server.SetDePacketor(httpDePacketor); }
public void SetDePacketor(DePacketor _dePacketor) { if (!isStop || _dePacketor == null) { return; } if (_dePacketor == dePacketor) { return; } dePacketor = _dePacketor; }
private int GetHttpPackDataLength(DePacketor dePacket, byte[] pack, int offset, int packLen, out int realPackHeadLen) { for (int i = offset; i < packLen - 3; i++) { if (pack[i] == '\r' && pack[i + 1] == '\n' && pack[i + 2] == '\r' && pack[i + 3] == '\n') { realPackHeadLen = i + 4; return(0); } } realPackHeadLen = -1; return(-1); }
public void SetSocketState(SocketState state) { socketState = state; if ((socketState == SocketState.CONNECTED_SERVER || socketState == SocketState.CONNECTTING_SERVER) && remoteServerInfo != null && remoteServerInfo.dePacketor != null) { dePacketor = remoteServerInfo.dePacketor; } else { Server server = serverTask.GetServer(); dePacketor = server.dePacketor; } unPackHeadLen = dePacketor.GetPackHeadPreLength(); }
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; }
public abstract void SetDePacketor(DePacketor dePacketor);
public override void SetDePacketor(DePacketor dePacketor) { dePacketor.SetUnPackCallBack(UnPack, this); }