private void AddStateFromEntry(NetGraphBuilder builder, StateGraphEntry entry, BaseNodeFactory inputNode, BaseNodeFactory outputNode, bool clientToServer) { BaseNodeFactory currentFactory; if (entry.Graph != null) { currentFactory = builder.AddNode(new NetGraphContainerNodeFactory(String.Format("{0} {1}", entry.StateName, GetDirection(clientToServer)), Guid.NewGuid(), entry.Graph.Factory, clientToServer ? NetGraphContainerNode.GraphDirection.ClientToServer : NetGraphContainerNode.GraphDirection.ServerToClient)); currentFactory.Hidden = true; builder.AddLine(inputNode, currentFactory, entry.StateName); } else { currentFactory = inputNode; } if (entry.LogPackets) { LogPacketNodeFactory log = builder.AddLog(String.Format("{0} Log {1}", entry.StateName, GetDirection(clientToServer)), Guid.NewGuid(), entry.Color, null, false); log.Hidden = true; builder.AddLine(currentFactory, log, null); currentFactory = log; } builder.AddLine(currentFactory, outputNode, null); }
/// <summary> /// Add a log node /// </summary> /// <param name="label">Label of the node</param> /// <param name="color">Color of the logged packet data</param> /// <param name="tag">Arbitrary string tag</param> /// <param name="convertToBytes">Whether to convert all logged packets to bytes only</param> /// <param name="guid">Guid of node</param> /// <returns>The log packet node factory</returns> public LogPacketNodeFactory AddLog(string label, Guid guid, ColorValue color, string tag, bool convertToBytes) { LogPacketNodeFactory log = new LogPacketNodeFactory(label, guid, color, tag, convertToBytes); AddNode(log); return(log); }
private LogPacketNodeFactory AddLog(NetGraphBuilder builder, StateGraphEntry entry, BaseNodeFactory currentFactory, bool clientToServer) { LogPacketNodeFactory log = builder.AddLog(String.Format("{0} Log {1}", entry.StateName, GetDirection(clientToServer)), Guid.NewGuid(), entry.Color, null, false); log.Hidden = true; builder.AddLine(currentFactory, log, null); return(log); }
/// <summary> /// Create a default proxy graph factory (contains two log elements and two end points) /// </summary> /// <param name="name">A name to associate with the graph</param> /// <returns>The new factory</returns> public static NetGraphFactory CreateDefaultProxyGraph(string name) { string prefix = name != null?String.Format("{0} - ", name) : String.Empty; NetGraphBuilder builder = new NetGraphBuilder(); ClientEndpointFactory client = builder.AddClient(prefix + "CLIENT", Guid.NewGuid()); ServerEndpointFactory server = builder.AddServer(prefix + "SERVER", Guid.NewGuid()); LogPacketNodeFactory logOut = builder.AddLog(prefix + "Out", Guid.NewGuid(), ColorValue.Pink, null, false); LogPacketNodeFactory logIn = builder.AddLog(prefix + "In", Guid.NewGuid(), ColorValue.Powderblue, null, false); builder.AddLines(server, logOut, client, logIn, server); return(builder.Factory); }
/// <summary> /// Guild the default graph factory /// </summary> /// <returns>The graph factory</returns> protected static NetGraphFactory BuildDefaultProxyFactory() { NetGraphBuilder builder = new NetGraphBuilder(); ServerEndpointFactory server = builder.AddServer("SERVER", Guid.NewGuid()); ClientEndpointFactory client = builder.AddClient("CLIENT", Guid.NewGuid()); LogPacketNodeFactory logOut = builder.AddLog("LOGOUT", Guid.NewGuid(), new ColorValue(0xFF, 0xC0, 0xCB, 0xFF), "Out", false); LogPacketNodeFactory logIn = builder.AddLog("LOGIN", Guid.NewGuid(), new ColorValue(0xB0, 0xE0, 0xE6, 0xFF), "In", false); builder.AddLine(server, logOut, null); builder.AddLine(logOut, client, null); builder.AddLine(client, logIn, null); builder.AddLine(logIn, server, null); return(builder.Factory); }
private SwitchNodeFactory CreateBaseGraph(NetGraphBuilder builder, BaseNodeFactory inputNode, BaseNodeFactory outputNode, bool clientToServer) { SwitchNodeFactory switchNode = builder.AddNode(new SwitchNodeFactory(String.Format("{0} Switch {1}", _metaName, GetDirection(clientToServer)), Guid.NewGuid(), false, CANAPE.Nodes.SwitchNodeSelectionMode.ExactMatch)); switchNode.Hidden = true; switchNode.SelectionPath = "#" + (String.IsNullOrWhiteSpace(_metaName) ? "Invalid" : _metaName.Trim()); builder.AddLine(inputNode, switchNode, null); LogPacketNodeFactory log = builder.AddLog(String.Format("Invalid Traffic {0}", GetDirection(clientToServer)), Guid.NewGuid(), new ColorValue(255, 0, 0), null, false); log.Hidden = true; builder.AddLine(switchNode, log, null); builder.AddLine(log, outputNode, null); return(switchNode); }
/// <summary> /// Create the test graph /// </summary> /// <param name="logger">The logger to use</param> /// <param name="globals">The global meta</param> /// <returns>The new test graph container</returns> /// <exception cref="ArgumentException">Throw if script invalid</exception> public override TestGraphContainer CreateTestGraph(Logger logger, MetaDictionary globals) { if (String.IsNullOrWhiteSpace(_config.ClassName)) { throw new ArgumentException(CANAPE.Documents.Properties.Resources.ScriptTestDocument_MustProvideClassname); } NetGraphBuilder builder = new NetGraphBuilder(); ServerEndpointFactory server = builder.AddServer("server", Guid.NewGuid()); DynamicNodeFactory node = builder.AddNode((DynamicNodeFactory)_config.CreateFactory()); LogPacketNodeFactory log = builder.AddLog("Test Network", Guid.NewGuid(), new ColorValue(0xFF, 0xFF, 0xFF, 0xFF), "Entry", false); ClientEndpointFactory client = builder.AddClient("client", Guid.NewGuid()); builder.AddLine(server, node, null); builder.AddLine(node, log, null); builder.AddLine(log, client, null); NetGraph graph = builder.Factory.Create(logger, null, globals, new MetaDictionary(), new PropertyBag("Connection")); return(new TestGraphContainer(graph, graph.Nodes[server.Id], graph.Nodes[client.Id])); }