public static profileStart ( string name ) : void | ||
name | string | |
Результат | void |
public override void process(byte[] datas, MessageLengthEx offset, MessageLengthEx length) { MessageLengthEx totallen = offset; while (length > 0 && expectSize > 0) { if (state == READ_STATE.READ_STATE_MSGID) { if (length >= expectSize) { Array.Copy(datas, totallen, stream.data(), stream.wpos, expectSize); totallen += expectSize; stream.wpos += (int)expectSize; length -= expectSize; msgid = stream.readUint16(); stream.clear(); Message msg = Messages.clientMessages[msgid]; if (msg.msglen == -1) { state = READ_STATE.READ_STATE_MSGLEN; expectSize = 2; } else if (msg.msglen == 0) { // 如果是0个参数的消息,那么没有后续内容可读了,处理本条消息并且直接跳到下一条消息 #if UNITY_EDITOR Dbg.profileStart(msg.name); #endif msg.handleMessage(stream); #if UNITY_EDITOR Dbg.profileEnd(msg.name); #endif state = READ_STATE.READ_STATE_MSGID; expectSize = 2; } else { expectSize = (MessageLengthEx)msg.msglen; state = READ_STATE.READ_STATE_BODY; } } else { Array.Copy(datas, totallen, stream.data(), stream.wpos, length); stream.wpos += (int)length; expectSize -= length; break; } } else if (state == READ_STATE.READ_STATE_MSGLEN) { if (length >= expectSize) { Array.Copy(datas, totallen, stream.data(), stream.wpos, expectSize); totallen += expectSize; stream.wpos += (int)expectSize; length -= expectSize; msglen = stream.readUint16(); stream.clear(); // 长度扩展 if (msglen >= 65535) { state = READ_STATE.READ_STATE_MSGLEN_EX; expectSize = 4; } else { state = READ_STATE.READ_STATE_BODY; expectSize = msglen; } } else { Array.Copy(datas, totallen, stream.data(), stream.wpos, length); stream.wpos += (int)length; expectSize -= length; break; } } else if (state == READ_STATE.READ_STATE_MSGLEN_EX) { if (length >= expectSize) { Array.Copy(datas, totallen, stream.data(), stream.wpos, expectSize); totallen += expectSize; stream.wpos += (int)expectSize; length -= expectSize; expectSize = stream.readUint32(); stream.clear(); state = READ_STATE.READ_STATE_BODY; } else { Array.Copy(datas, totallen, stream.data(), stream.wpos, length); stream.wpos += (int)length; expectSize -= length; break; } } else if (state == READ_STATE.READ_STATE_BODY) { if (length >= expectSize) { stream.append(datas, totallen, expectSize); totallen += expectSize; length -= expectSize; Message msg = Messages.clientMessages[msgid]; #if UNITY_EDITOR Dbg.profileStart(msg.name); #endif msg.handleMessage(stream); #if UNITY_EDITOR Dbg.profileEnd(msg.name); #endif stream.clear(); state = READ_STATE.READ_STATE_MSGID; expectSize = 2; } else { stream.append(datas, totallen, length); expectSize -= length; break; } } } }