public void HandleMessage(byte[] data, int size) { if (data.Length == 0 || 0 == size) { Log.TraceError("Error, HandleMessage data is 0 "); return; } //byte[] byteTemp = new byte[size]; //System.Array.Copy(data, 0, byteTemp, 0, size); //init LoadArchive //LoadArchive loadAr = new LoadArchive(byteTemp, 0, byteTemp.Length); //LoadArchive loadAr = new LoadArchive(data, 0, size); int protocolId = data[0]; /*int protocolId = 0; * bool bRet = loadAr.ReadInt8(ref protocolId); * if (!bRet) * { * //Log.Trace("SocketReceiveHandle::HandleMessage parse get protocol id failed!"); * return; * }*/ //if (protocolId == GlobalServerMsg.SERVER_IDLE) //{ // //不处理 // return; //} /* * LoadArchive loadAr = new LoadArchive(data, 0, data.Length); * loadAr.Seek(1); * * int nArgNum = 0; * loadAr.ReadInt16(ref nArgNum); * int nType = 0; * loadAr.ReadInt8(ref nType); * int value = 0; * loadAr.ReadInt32(ref value); * * if (value.Equals(1401)) * { * loadAr.ReadInt8(ref nType); * int type = 0; * loadAr.ReadInt32(ref type); * if (type.Equals(1)) * { * Log.Trace("Receive msg id = " + value); * } * } */ ExcuteEvent(protocolId, data); if (protocolId.Equals(GlobalServerMsg.SERVER_CP_CUSTOM)) { byte[] content = new byte[data.Length - 1]; System.Array.Copy(data, 1, content, 0, content.Length); byte[] contentBytes = QuickLZ.decompress(content); byte[] dataTemp = new byte[contentBytes.Length + 1]; System.Array.Copy(data, 0, dataTemp, 0, 1); //拷贝消息id System.Array.Copy(contentBytes, 0, dataTemp, 1, contentBytes.Length); //拷贝解压后消息体(除去消息头) data = dataTemp; } if (protocolId.Equals(GlobalServerMsg.SERVER_CUSTOM) || protocolId.Equals(GlobalServerMsg.SERVER_CP_CUSTOM)) { LoadArchive loadAr = new LoadArchive(data, 0, data.Length); loadAr.Seek(1); int nArgNum = 0; loadAr.ReadInt16(ref nArgNum); int nType = 0; loadAr.ReadInt8(ref nType); loadAr.ReadInt32(ref protocolId); } CustomSystem.Instance.dispacthEvent(0, protocolId); }