public static MsgTypeToString ( short value ) : string | ||
value | short | A internal message id value. |
return | string |
public override string ToString() { return(string.Concat(new object[] { MsgType.MsgTypeToString(this.msgType), ": count=", this.count, " bytes=", this.bytes })); }
internal void ResumeHandling() { // pauseQueue is null if Resume called without pausing, make sure to only do something if paused before. if (pauseQueue != null) { foreach (NetworkMessage msg in pauseQueue) { if (LogFilter.logWarn) { Debug.LogWarning("processing queued message: " + msg.msgType + " str=" + MsgType.MsgTypeToString(msg.msgType)); } var msgDelegate = m_MessageHandlersDict[msg.msgType]; msgDelegate(msg); } pauseQueue = null; } }
public override string ToString() { return(MsgType.MsgTypeToString(msgType) + ": count=" + count + " bytes=" + bytes); }
protected void HandleReader( NetworkReader reader, int receivedSize, int channelId) { // read until size is reached. // NOTE: stream.Capacity is 1300, NOT the size of the available data while (reader.Position < receivedSize) { // the reader passed to user code has a copy of bytes from the real stream. user code never touches the real stream. // this ensures it can never get out of sync if user code reads less or more than the real amount. ushort sz = reader.ReadUInt16(); short msgType = reader.ReadInt16(); // create a reader just for this message byte[] msgBuffer = reader.ReadBytes(sz); NetworkReader msgReader = new NetworkReader(msgBuffer); if (logNetworkMessages) { StringBuilder msg = new StringBuilder(); for (int i = 0; i < sz; i++) { msg.AppendFormat("{0:X2}", msgBuffer[i]); if (i > k_MaxMessageLogSize) { break; } } Debug.Log("ConnectionRecv con:" + connectionId + " bytes:" + sz + " msgId:" + msgType + " " + msg); } NetworkMessageDelegate msgDelegate = null; if (m_MessageHandlersDict.ContainsKey(msgType)) { msgDelegate = m_MessageHandlersDict[msgType]; } if (msgDelegate != null) { // create message here instead of caching it. so we can add it to queue more easily. NetworkMessage msg = new NetworkMessage(); msg.msgType = msgType; msg.reader = msgReader; msg.conn = this; msg.channelId = channelId; // add to queue while paused, otherwise process directly if (pauseQueue != null) { pauseQueue.Enqueue(msg); if (LogFilter.logWarn) { Debug.LogWarning("HandleReader: added message to pause queue: " + msgType + " str=" + MsgType.MsgTypeToString(msgType) + " queue size=" + pauseQueue.Count); } } else { msgDelegate(msg); } lastMessageTime = Time.time; #if UNITY_EDITOR UnityEditor.NetworkDetailStats.IncrementStat( UnityEditor.NetworkDetailStats.NetworkDirection.Incoming, MsgType.HLAPIMsg, "msg", 1); if (msgType > MsgType.Highest) { UnityEditor.NetworkDetailStats.IncrementStat( UnityEditor.NetworkDetailStats.NetworkDirection.Incoming, MsgType.UserMessage, msgType.ToString() + ":" + msgType.GetType().Name, 1); } #endif #if UNITY_EDITOR if (m_PacketStats.ContainsKey(msgType)) { PacketStat stat = m_PacketStats[msgType]; stat.count += 1; stat.bytes += sz; } else { PacketStat stat = new PacketStat(); stat.msgType = msgType; stat.count += 1; stat.bytes += sz; m_PacketStats[msgType] = stat; } #endif } else { //NOTE: this throws away the rest of the buffer. Need moar error codes if (LogFilter.logError) { Debug.LogError("Unknown message ID " + msgType + " connId:" + connectionId); } break; } } }
public override string ToString() { return(MsgType.MsgTypeToString(this.msgType) + ": count=" + (object)this.count + " bytes=" + (object)this.bytes); }
public override string ToString() { object[] objArray1 = new object[] { MsgType.MsgTypeToString(this.msgType), ": count=", this.count, " bytes=", this.bytes }; return(string.Concat(objArray1)); }