int ShowClientMessageHandlers(Rect r, int posY) { if (NetworkClient.allClients.Count == 0) { return(posY); } NetworkClient client = NetworkClient.allClients[0]; if (client == null) { return(posY); } GUI.Label(new Rect(r.xMin + k_Padding, posY, 400, k_RowHeight), m_ShowClientMessagesLabel); posY += k_RowHeight; foreach (var handler in client.handlers) { GUI.Label(new Rect(r.xMin + k_Padding * 4, posY, 400, k_RowHeight), MsgType.MsgTypeToString(handler.Key)); GUI.Label(new Rect(r.xMin + k_Padding * 4 + k_ColumnWidth, posY, 400, k_RowHeight), FormatHandler(handler)); posY += k_RowHeight; } return(posY); }
/// <summary> /// Peertype message is the first message received whenever a new client is connected. /// </summary> /// <param name="netMsg">The NetworkMessage Recieved</param> void PeerTypeHandler(NetworkMessage netMsg) { var pt = (PeerType)netMsg.ReadMessage <IntegerMessage>().value; if (LogFilter.logDebug) { Debug.Log("Receive PeerType Message: " + pt.ToString()); } var connid = netMsg.conn.connectionId; var strkey = MsgType.MsgTypeToString(MsgType.PeerType); if (!peerinfo.ContainsKey(connid)) { peerinfo[connid] = new Dictionary <string, object>(); } peerinfo[connid][strkey] = pt; if (pt == PeerType.Environment) { envconnid.Add(connid); uicontroller.SyncCurrentDisplayCLUT(new List <NetworkConnection> { netMsg.conn }); } // if there are VLabAnalysis already connected, then VLabAnalysisManager is already there // and server will automatically spwan scene and network objects(including VLabAnalysisManager) to // newly conneted client. if not, then this is the first time a VLabAnalysis client connected, // so we need to create a new instance of VLabAnalysisManager and spwan to all clients, // this may include VLabEnvironment, but since they doesn't register for the VLabAnalysisManager prefab, // they will spawn nothing. if ((pt == PeerType.Analysis) && (uicontroller.alsmanager == null)) { SpwanVLAnalysisManager(); } }
private int ShowClientMessageHandlers(Rect r, int posY) { if (NetworkClient.allClients.Count == 0) { return(posY); } NetworkClient allClient = NetworkClient.allClients[0]; if (allClient == null) { return(posY); } GUI.Label(new Rect(r.xMin + 4f, (float)posY, 400f, 16f), this.m_ShowClientMessagesLabel); posY += 16; using (Dictionary <short, NetworkMessageDelegate> .Enumerator enumerator = allClient.handlers.GetEnumerator()) { while (enumerator.MoveNext()) { KeyValuePair <short, NetworkMessageDelegate> current = enumerator.Current; GUI.Label(new Rect(r.xMin + 16f, (float)posY, 400f, 16f), MsgType.MsgTypeToString(current.Key)); GUI.Label(new Rect((float)((double)r.xMin + 16.0 + 120.0), (float)posY, 400f, 16f), NetworkManagerPreview.FormatHandler(current)); posY += 16; } } return(posY); }
void OnGUI() { int posY = 80; foreach (PacketStatInfo stat in packetStats.Values) { GUI.Label(new Rect(10, posY, 460, 20), "Msg: " + MsgType.MsgTypeToString(stat.msgId) + " Count: " + stat.packets.GetAverage() + "/sec Bytes: " + stat.bytes.GetAverage() + "/sec"); posY += 20; } }
public bool IsConnectionPeerType(NetworkConnection conn, PeerType peertype) { if (conn == null) { return(false); } var cid = conn.connectionId; var strkey = MsgType.MsgTypeToString(MsgType.PeerType); return(peerinfo.ContainsKey(cid) && peerinfo[cid].ContainsKey(strkey) && (PeerType)peerinfo[cid][strkey] == peertype); }
// Methods /// <summary> /// See <see cref="MsgType.MsgTypeToString(short)"/>. /// </summary> public static new string MsgTypeToString(short value) { string messageTypeString; if (messageTypeStrings.TryGetValue(value, out messageTypeString)) { return(messageTypeString); } return(MsgType.MsgTypeToString(value)); }
public bool IsPeerTypeConnected(PeerType peertype, int[] excludeconns) { foreach (var cid in peerinfo.Keys.Except(excludeconns)) { var pi = peerinfo[cid]; var strkey = MsgType.MsgTypeToString(MsgType.PeerType); if (pi != null && pi.ContainsKey(strkey) && (PeerType)pi[strkey] == peertype) { return(true); } } return(false); }
private int ShowServerMessageHandlers(Rect r, int posY) { if (NetworkServer.handlers.Count != 0) { GUI.Label(new Rect(r.xMin + 4f, (float)posY, 400f, 16f), this.m_ShowServerMessagesLabel); posY += 0x10; foreach (KeyValuePair <short, NetworkMessageDelegate> pair in NetworkServer.handlers) { GUI.Label(new Rect(r.xMin + 16f, (float)posY, 400f, 16f), MsgType.MsgTypeToString(pair.Key)); GUI.Label(new Rect((r.xMin + 16f) + 120f, (float)posY, 400f, 16f), FormatHandler(pair)); posY += 0x10; } } return(posY); }
int ShowServerMessageHandlers(Rect r, int posY) { if (NetworkServer.handlers.Count == 0) { return(posY); } GUI.Label(new Rect(r.xMin + k_Padding, posY, 400, k_RowHeight), m_ShowServerMessagesLabel); posY += k_RowHeight; foreach (var handler in NetworkServer.handlers) { GUI.Label(new Rect(r.xMin + k_Padding * 4, posY, 400, k_RowHeight), MsgType.MsgTypeToString(handler.Key)); GUI.Label(new Rect(r.xMin + k_Padding * 4 + k_ColumnWidth, posY, 400, k_RowHeight), FormatHandler(handler)); posY += k_RowHeight; } return(posY); }
void AspectRatioHandler(NetworkMessage netMsg) { //var r = netMsg.ReadMessage<FloatMessage>().value; var r = float.Parse(netMsg.ReadMessage <StringMessage>().value); if (LogFilter.logDebug) { Debug.Log("Receive AspectRatio Message: " + r.ToString()); } var connid = netMsg.conn.connectionId; var strkey = MsgType.MsgTypeToString(MsgType.AspectRatio); if (!peerinfo.ContainsKey(connid)) { peerinfo[connid] = new Dictionary <string, object>(); } peerinfo[connid][strkey] = r; uicontroller.OnAspectRatioMessage(r); }
private int ShowClientMessageHandlers(Rect r, int posY) { if (NetworkClient.allClients.Count != 0) { NetworkClient client = NetworkClient.allClients[0]; if (client == null) { return(posY); } GUI.Label(new Rect(r.xMin + 4f, (float)posY, 400f, 16f), this.m_ShowClientMessagesLabel); posY += 0x10; foreach (KeyValuePair <short, NetworkMessageDelegate> pair in client.handlers) { GUI.Label(new Rect(r.xMin + 16f, (float)posY, 400f, 16f), MsgType.MsgTypeToString(pair.Key)); GUI.Label(new Rect((r.xMin + 16f) + 120f, (float)posY, 400f, 16f), FormatHandler(pair)); posY += 0x10; } } return(posY); }
// Converts a MsgType OR ConnectFourMsgType to a string, including the class portion public static string MsgTypeToString(short msgType) { return(msgType <= MsgType.Highest ? "MsgType." + MsgType.MsgTypeToString(msgType) : "ConnectFourMsgType." + ConnectFourMsgType.MsgTypeToString(msgType)); }