public void GetDataStatistics(Stream stream, StormancerClientViewModel clientVM, StormancerRouteViewModel route)
 {
     route.sizeStack  += stream.Length;
     route.messageNbr += 1;
     if (route.averageSizeChart.Count == 0)
     {
         route.averageSize = stream.Length;
     }
     else
     {
         route.averageSize = (route.averageSize * (route.messageNbr - 1) + stream.Length) / route.messageNbr;
     }
 }
コード例 #2
0
        private void UpdateRouteData(StormancerClientViewModel clientVM, StormancerRouteViewModel route)
        {
            if (route.dataChart.Count >= 3600)
                route.dataChart.RemoveAt(0);
            if (route.messageNbrChart.Count >= 3600)
                route.messageNbrChart.RemoveAt(0);
            if (route.averageSizeChart.Count >= 3600)
                route.averageSizeChart.RemoveAt(0);
            route.debit = route.sizeStack;
            route.curve.AddKey(clientVM.client.Clock, route.sizeStack);
            route.dataChart.Add(route.sizeStack);
            route.messageNbrChart.Add(route.messageNbr);
            route.averageSizeChart.Add(route.averageSize);

            route.messageNbr = 0;
            route.sizeStack = 0;
        }
コード例 #3
0
        private void ShowScene(int i, StormancerClientViewModel c)
		{
			int j = 0;

			folds[i].scene = EditorGUILayout.Foldout(folds[i].scene, "scenes");
			if (folds[i].scene)
			{
				EditorGUI.indentLevel++;
			foreach(StormancerSceneViewModel v in c.scenes.Values)	
				{
					if (folds[i].scenes.Count - 1 < j)
						folds[i].scenes.Add(new SceneFolds());
					EditorGUI.indentLevel++;

                    EditorGUILayout.BeginHorizontal(GUILayout.Width(200), GUILayout.Height(20), GUILayout.MinWidth(100), GUILayout.MaxWidth(300));
    				folds[i].scenes[j].routes = EditorGUILayout.Foldout(folds[i].scenes[j].routes, v.scene.Id);
                    //EditorGUILayout.Toggle("        ", v.connected);
                    if (GUILayout.Button("show logs", GUILayout.Width(100)) && logsToShow == null)
                    {
                        logsToShow = v.log;
                        log_scroll = Vector2.zero;
                    }
                    EditorGUILayout.EndHorizontal();

					if (folds[i].scenes[j].routes == true)
                    {
						EditorGUI.indentLevel++;
                        folds[i].scenes[j].serverRoutes = EditorGUILayout.Foldout(folds[i].scenes[j].serverRoutes, "server routes");
                        if (folds[i].scenes[j].serverRoutes == true)
                        {
                            EditorGUI.indentLevel++;

                            foreach (StormancerRouteViewModel route in v.remotes.Values.OrderBy(r=>r.Name))
                            {
                                GUILayout.BeginHorizontal(GUILayout.Width(400), GUILayout.Height(20), GUILayout.MinWidth(400), GUILayout.MaxWidth(window.position.width / 4));
                                EditorGUILayout.LabelField(route.Name + "     " + route.debit.ToString() + " b/s");
                                if (GUILayout.Button("Show Chart", GUILayout.Width(90)))
                                {
                                    routeToShow = route;
                                }
                                //EditorGUILayout.CurveField(route.curve);
                                GUILayout.EndHorizontal();
                            }
                            EditorGUI.indentLevel--;
                        }
                        folds[i].scenes[j].localRoutes = EditorGUILayout.Foldout(folds[i].scenes[j].localRoutes, "local routes");
                        if (folds[i].scenes[j].localRoutes == true)
                        {
                            EditorGUI.indentLevel++;
                            foreach (StormancerRouteViewModel route in v.routes.Values.OrderBy(r => r.Name))
                            {
                                GUILayout.BeginHorizontal(GUILayout.Width(300), GUILayout.Height(20), GUILayout.MinWidth(150), GUILayout.MaxWidth(400));
                                EditorGUILayout.LabelField(route.Name + "     " + route.debit.ToString() + " b/s");
                                if (GUILayout.Button("Show Chart", GUILayout.Width(90)))
                                {
                                    routeToShow = route;
                                }
                                //EditorGUILayout.CurveField(route.curve);
                                GUILayout.EndHorizontal();
                            }
                            EditorGUI.indentLevel--;
                        }
						EditorGUI.indentLevel--;
					}
					EditorGUI.indentLevel--;
					j++;
				}
				EditorGUI.indentLevel--;
			}
		}
コード例 #4
0
        public void Build(PluginBuildContext ctx)
        {

            ctx.ClientCreated += client =>
            {
                var innerLoggerFactory = client.DependencyResolver.GetComponent<ILogger>();
                _clientVM = new StormancerClientViewModel(client);
                client.DependencyResolver.RegisterComponent<ILogger>(() => new InterceptorLogger(innerLoggerFactory, _clientVM));
                StormancerEditorDataCollector.Instance.clients.TryAdd(_id, _clientVM);
            };

            ctx.ClientDestroyed += client =>
            {
                StormancerClientViewModel temp;
                StormancerEditorDataCollector.Instance.clients.TryRemove(_id, out temp);
            };

            ctx.SceneCreated += scene =>
           {
               _clientVM.scenes.TryAdd(scene.Id, new StormancerSceneViewModel(scene));
           };

            ctx.SceneConnected += scene =>
            {
                if (StormancerEditorDataCollector.Instance.clients.ContainsKey(_id))
                {
                    if (StormancerEditorDataCollector.Instance.clients[_id].scenes.ContainsKey(scene.Id))
                        StormancerEditorDataCollector.Instance.clients[_id].scenes[scene.Id].connected = true;
                }
            };

            ctx.SceneDisconnected += scene =>
            {
                if (StormancerEditorDataCollector.Instance.clients.ContainsKey(_id))
                {
                    if (StormancerEditorDataCollector.Instance.clients[_id].scenes.ContainsKey(scene.Id))
                        StormancerEditorDataCollector.Instance.clients[_id].scenes[scene.Id].connected = false;
                }
            };

            ctx.RouteCreated += (Scene scene, Route route) =>
            {
                StormancerSceneViewModel sceneVM;
                if (_clientVM.scenes.TryGetValue(scene.Id, out sceneVM))
                {
                    sceneVM.routes.TryAdd(route.Name, new StormancerRouteViewModel(route));
                }
            };

            ctx.PacketReceived += (Packet packet) =>
            {
                if (packet.Metadata.ContainsKey("scene"))
                {
                    var scene = (Scene)packet.Metadata["scene"];
                    StormancerSceneViewModel sceneVM;
                    if (_clientVM.scenes.TryGetValue(scene.Id, out sceneVM))
                    {
                        var routeId = (ushort)packet.Metadata["routeId"];
                        var temp = sceneVM.routes.Values.FirstOrDefault(r => r.Handle == routeId);
                        if (temp != null)
                        {
                            temp.sizeStack += packet.Stream.Length;
                            temp.messageNbr += 1;
                            if (temp.messageNbr == 1)
                                temp.averageSize = packet.Stream.Length;
                            else
                                temp.averageSize = (temp.averageSize * (temp.messageNbr - 1) + packet.Stream.Length) / temp.messageNbr;

                            if (temp.lastUpdate + 1000 < _clientVM.client.Clock)
                            {
                                if (temp.dataChart.Count >= 10800)
                                    temp.dataChart.RemoveAt(0);
                                if (temp.messageNbrChart.Count >= 10800)
                                    temp.messageNbrChart.RemoveAt(0);
                                if (temp.averageSizeChart.Count >= 10800)
                                    temp.averageSizeChart.RemoveAt(0);
                                temp.debit = temp.sizeStack;
                                temp.lastUpdate = _clientVM.client.Clock;
                                temp.curve.AddKey(_clientVM.client.Clock, temp.sizeStack);
                                temp.dataChart.Add(temp.sizeStack);
                                temp.messageNbrChart.Add(temp.messageNbr);
                                temp.averageSizeChart.Add(temp.averageSize);

                                temp.messageNbr = 0;
                                temp.averageSize = 0;
                                temp.sizeStack = 0;
                            }
                        }
                    }
                }
            };
        }
コード例 #5
0
 public InterceptorLogger(ILogger innerLogger, StormancerClientViewModel client)
 {
     _innerLogger = innerLogger;
     _clientVM = client;
 }
コード例 #6
0
 public void GetDataStatistics(Stream stream, StormancerClientViewModel clientVM, StormancerRouteViewModel route)
 {
     route.sizeStack += stream.Length;
     route.messageNbr += 1;
     if (route.averageSizeChart.Count == 0)
         route.averageSize = stream.Length;
     else
         route.averageSize = (route.averageSize * (route.messageNbr - 1) + stream.Length) / route.messageNbr;
 }
コード例 #7
0
        public void Build(PluginBuildContext ctx)
        {
            ctx.ClientCreated += client =>
            {
                var innerLoggerFactory = client.DependencyResolver.Resolve <ILogger>();
                _clientVM    = new StormancerClientViewModel(client);
                _clientVM.id = _id;
                client.DependencyResolver.Register <ILogger>(() => new InterceptorLogger(innerLoggerFactory, _clientVM));
                StormancerEditorDataCollector.Instance.clients.TryAdd(_id, _clientVM);
            };

            ctx.ClientDestroyed += client =>
            {
                StormancerClientViewModel temp;
                StormancerEditorDataCollector.Instance.clients.TryRemove(_id, out temp);
            };

            ctx.SceneCreated += scene =>
            {
                _clientVM.scenes.TryAdd(scene.Id, new StormancerSceneViewModel(scene));
            };

            ctx.SceneConnected += scene =>
            {
                if (StormancerEditorDataCollector.Instance.clients.ContainsKey(_id))
                {
                    if (StormancerEditorDataCollector.Instance.clients[_id].scenes.ContainsKey(scene.Id))
                    {
                        StormancerEditorDataCollector.Instance.clients[_id].scenes[scene.Id].connected = true;
                    }
                }
            };

            ctx.SceneDisconnected += scene =>
            {
                if (StormancerEditorDataCollector.Instance.clients.ContainsKey(_id))
                {
                    if (StormancerEditorDataCollector.Instance.clients[_id].scenes.ContainsKey(scene.Id))
                    {
                        StormancerEditorDataCollector.Instance.clients[_id].scenes[scene.Id].connected = false;
                    }
                }
            };

            ctx.RouteCreated += (Scene scene, Route route) =>
            {
                StormancerSceneViewModel sceneVM;
                if (_clientVM.scenes.TryGetValue(scene.Id, out sceneVM))
                {
                    sceneVM.routes.TryAdd(route.Name, new StormancerRouteViewModel(route));
                }
            };

            ctx.PacketReceived += (Packet packet) =>
            {
                if (_clientVM != null && _clientVM.exportLogs == true)
                {
                    var pos     = packet.Stream.Position;
                    var message = new List <byte>();
                    var buffer  = new byte[1024];

                    int readByte = 0;
                    do
                    {
                        readByte = packet.Stream.Read(buffer, 0, 1024);
                        message.AddRange(buffer.Take(readByte));
                    }while (readByte > 0);
                    packet.Stream.Seek(pos, SeekOrigin.Begin);

                    var scene   = (Scene)packet.Metadata["scene"];
                    var routeId = (ushort)packet.Metadata["routeId"];

                    StormancerRouteViewModel routeVM = null;
                    StormancerSceneViewModel sceneVM = null;
                    string route = "";
                    if (_clientVM.scenes.TryGetValue(scene.Id, out sceneVM))
                    {
                        routeVM = sceneVM.routes.Values.FirstOrDefault(r => r.Handle == routeId);
                    }
                    if (routeVM != null)
                    {
                        route = routeVM.Name;
                    }
                    if (route == "")
                    {
                        route = "system";
                    }
                    _clientVM.WritePacketLog(true, scene.Id, route, message);
                }
            };

            ctx.PacketReceived += (Packet packet) =>
            {
                if (packet.Metadata.ContainsKey("scene"))
                {
                    var scene = (Scene)packet.Metadata["scene"];
                    StormancerSceneViewModel sceneVM;
                    if (_clientVM.scenes.TryGetValue(scene.Id, out sceneVM))
                    {
                        var routeId = (ushort)packet.Metadata["routeId"];
                        var temp    = sceneVM.routes.Values.FirstOrDefault(r => r.Handle == routeId);
                        if (temp != null)
                        {
                            StormancerEditorDataCollector.Instance.GetDataStatistics(packet.Stream, _clientVM, temp);
                        }
                    }
                }
            };
        }
コード例 #8
0
 public InterceptorLogger(ILogger innerLogger, StormancerClientViewModel client)
 {
     _innerLogger = innerLogger;
     _clientVM    = client;
 }
コード例 #9
0
        public void Build(PluginBuildContext ctx)
        {

            ctx.ClientCreated += client =>
            {
                var innerLoggerFactory = client.DependencyResolver.Resolve<ILogger>();
                _clientVM = new StormancerClientViewModel(client);
                _clientVM.id = _id;
                client.DependencyResolver.Register<ILogger>(() => new InterceptorLogger(innerLoggerFactory, _clientVM));
                StormancerEditorDataCollector.Instance.clients.TryAdd(_id, _clientVM);
            };

            ctx.ClientDestroyed += client =>
            {
                StormancerClientViewModel temp;
                StormancerEditorDataCollector.Instance.clients.TryRemove(_id, out temp);
            };

            ctx.SceneCreated += scene =>
           {
               _clientVM.scenes.TryAdd(scene.Id, new StormancerSceneViewModel(scene));
           };

            ctx.SceneConnected += scene =>
            {
                if (StormancerEditorDataCollector.Instance.clients.ContainsKey(_id))
                {
                    if (StormancerEditorDataCollector.Instance.clients[_id].scenes.ContainsKey(scene.Id))
                        StormancerEditorDataCollector.Instance.clients[_id].scenes[scene.Id].connected = true;
                }
            };

            ctx.SceneDisconnected += scene =>
            {
                if (StormancerEditorDataCollector.Instance.clients.ContainsKey(_id))
                {
                    if (StormancerEditorDataCollector.Instance.clients[_id].scenes.ContainsKey(scene.Id))
                        StormancerEditorDataCollector.Instance.clients[_id].scenes[scene.Id].connected = false;
                }
            };

            ctx.RouteCreated += (Scene scene, Route route) =>
            {
                StormancerSceneViewModel sceneVM;
                if (_clientVM.scenes.TryGetValue(scene.Id, out sceneVM))
                {
                    sceneVM.routes.TryAdd(route.Name, new StormancerRouteViewModel(route));
                }
            };

            ctx.PacketReceived += (Packet packet) =>
            {
                if (_clientVM != null && _clientVM.exportLogs == true)
                {
                    var pos = packet.Stream.Position;
                    var message = new List<byte>();
                    var buffer = new byte[1024];

                    int readByte = 0;
                    do
                    {
                        readByte = packet.Stream.Read(buffer, 0, 1024);
                        message.AddRange(buffer.Take(readByte));
                    }
                    while (readByte > 0);
                    packet.Stream.Seek(pos, SeekOrigin.Begin);

                    var scene = (Scene)packet.Metadata["scene"];
                    var routeId = (ushort)packet.Metadata["routeId"];

                    StormancerRouteViewModel routeVM = null;
                    StormancerSceneViewModel sceneVM = null;
                    string route = "";
                    if (_clientVM.scenes.TryGetValue(scene.Id, out sceneVM))
                        routeVM = sceneVM.routes.Values.FirstOrDefault(r => r.Handle == routeId);
                    if (routeVM != null)
                        route = routeVM.Name;
                    if (route == "")
                        route = "system";
                    _clientVM.WritePacketLog(true, scene.Id, route, message);
                }
            };

            ctx.PacketReceived += (Packet packet) =>
            {
                if (packet.Metadata.ContainsKey("scene"))
                {
                    var scene = (Scene)packet.Metadata["scene"];
                    StormancerSceneViewModel sceneVM;
                    if (_clientVM.scenes.TryGetValue(scene.Id, out sceneVM))
                    {
                        var routeId = (ushort)packet.Metadata["routeId"];
                        var temp = sceneVM.routes.Values.FirstOrDefault(r => r.Handle == routeId);
                        if (temp != null)
                        {
                            StormancerEditorDataCollector.Instance.GetDataStatistics(packet.Stream, _clientVM, temp);
                        }
                    }
                }
            };
        }
コード例 #10
0
        public void Build(PluginBuildContext ctx)
        {
            ctx.ClientCreated += client =>
            {
                var innerLoggerFactory = client.DependencyResolver.GetComponent <ILogger>();
                _clientVM = new StormancerClientViewModel(client);
                client.DependencyResolver.RegisterComponent <ILogger>(() => new InterceptorLogger(innerLoggerFactory, _clientVM));
                StormancerEditorDataCollector.Instance.clients.TryAdd(_id, _clientVM);
            };

            ctx.ClientDestroyed += client =>
            {
                StormancerClientViewModel temp;
                StormancerEditorDataCollector.Instance.clients.TryRemove(_id, out temp);
            };

            ctx.SceneCreated += scene =>
            {
                _clientVM.scenes.TryAdd(scene.Id, new StormancerSceneViewModel(scene));
            };

            ctx.SceneConnected += scene =>
            {
                if (StormancerEditorDataCollector.Instance.clients.ContainsKey(_id))
                {
                    if (StormancerEditorDataCollector.Instance.clients[_id].scenes.ContainsKey(scene.Id))
                    {
                        StormancerEditorDataCollector.Instance.clients[_id].scenes[scene.Id].connected = true;
                    }
                }
            };

            ctx.SceneDisconnected += scene =>
            {
                if (StormancerEditorDataCollector.Instance.clients.ContainsKey(_id))
                {
                    if (StormancerEditorDataCollector.Instance.clients[_id].scenes.ContainsKey(scene.Id))
                    {
                        StormancerEditorDataCollector.Instance.clients[_id].scenes[scene.Id].connected = false;
                    }
                }
            };

            ctx.RouteCreated += (Scene scene, Route route) =>
            {
                StormancerSceneViewModel sceneVM;
                if (_clientVM.scenes.TryGetValue(scene.Id, out sceneVM))
                {
                    sceneVM.routes.TryAdd(route.Name, new StormancerRouteViewModel(route));
                }
            };

            ctx.PacketReceived += (Packet packet) =>
            {
                if (packet.Metadata.ContainsKey("scene"))
                {
                    var scene = (Scene)packet.Metadata["scene"];
                    StormancerSceneViewModel sceneVM;
                    if (_clientVM.scenes.TryGetValue(scene.Id, out sceneVM))
                    {
                        var routeId = (ushort)packet.Metadata["routeId"];
                        var temp    = sceneVM.routes.Values.FirstOrDefault(r => r.Handle == routeId);
                        if (temp != null)
                        {
                            temp.sizeStack  += packet.Stream.Length;
                            temp.messageNbr += 1;
                            if (temp.messageNbr == 1)
                            {
                                temp.averageSize = packet.Stream.Length;
                            }
                            else
                            {
                                temp.averageSize = (temp.averageSize * (temp.messageNbr - 1) + packet.Stream.Length) / temp.messageNbr;
                            }

                            if (temp.lastUpdate + 1000 < _clientVM.client.Clock)
                            {
                                if (temp.dataChart.Count >= 10800)
                                {
                                    temp.dataChart.RemoveAt(0);
                                }
                                if (temp.messageNbrChart.Count >= 10800)
                                {
                                    temp.messageNbrChart.RemoveAt(0);
                                }
                                if (temp.averageSizeChart.Count >= 10800)
                                {
                                    temp.averageSizeChart.RemoveAt(0);
                                }
                                temp.debit      = temp.sizeStack;
                                temp.lastUpdate = _clientVM.client.Clock;
                                temp.curve.AddKey(_clientVM.client.Clock, temp.sizeStack);
                                temp.dataChart.Add(temp.sizeStack);
                                temp.messageNbrChart.Add(temp.messageNbr);
                                temp.averageSizeChart.Add(temp.averageSize);

                                temp.messageNbr  = 0;
                                temp.averageSize = 0;
                                temp.sizeStack   = 0;
                            }
                        }
                    }
                }
            };
        }