예제 #1
0
        /// <summary>
        /// Rebuild the factory
        /// </summary>
        protected override void RebuildFactory()
        {
            NetGraphBuilder       builder = new NetGraphBuilder();
            ClientEndpointFactory client  = builder.AddClient("Client", Guid.NewGuid());

            client.Hidden = true;
            ServerEndpointFactory server = builder.AddServer("Server", Guid.NewGuid());

            server.Hidden = true;

            SwitchNodeFactory outputSwitch = CreateBaseGraph(builder, server, client, false);
            SwitchNodeFactory inputSwitch  = CreateBaseGraph(builder, client, server, true);

            AddStates(builder, outputSwitch, inputSwitch, client, server);

            NetGraphFactory factory = builder.Factory;

            factory.Properties.Add(_metaName, _defaultState);

            if (_factory == null)
            {
                _factory = factory;
            }
            else
            {
                _factory.UpdateGraph(factory);
            }

            Dirty = true;
        }
예제 #2
0
        /// <summary>
        /// Add a client node
        /// </summary>
        /// <param name="label">Label</param>
        /// <param name="guid">Guid of node</param>
        /// <returns>The client endpoint factory</returns>
        public ClientEndpointFactory AddClient(string label, Guid guid)
        {
            ClientEndpointFactory factory = new ClientEndpointFactory(label, guid);

            AddNode(factory);

            return(factory);
        }
예제 #3
0
        public static async Task <ClientEndpoint> Create()
        {
            var endpoint = new ClientEndpoint();

            var proxy = await ClientEndpointFactory
                        .CreateObjectReference(endpoint);

            return(endpoint.Initialize(proxy));
        }
예제 #4
0
        /// <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);
        }
예제 #5
0
        /// <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);
        }
예제 #6
0
        /// <summary>
        /// Constructor
        /// </summary>
        /// <param name="logger">The logger</param>
        /// <param name="config">Configuration for the server</param>
        public FullHttpProxyServer(HttpProxyServerConfig config, Logger logger)
            : base(logger)
        {
            _config = config;

            NetGraphBuilder builder = new NetGraphBuilder();

            ClientEndpointFactory client = builder.AddClient("Client", Guid.NewGuid());
            ServerEndpointFactory server = builder.AddServer("Server", Guid.NewGuid());

            DirectNodeFactory nop = builder.AddNode(new DirectNodeFactory("NOP", Guid.NewGuid()));

            builder.AddLines(client, nop, server, client);

            _factory = builder.Factory;
        }
예제 #7
0
        /// <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]));
        }
예제 #8
0
        private void btnInject_Click(object sender, EventArgs e)
        {
            if (_injectGraph != null)
            {
                CancelInject();
            }
            else
            {
                try
                {
                    NetGraph selectedGraph = comboBoxConnection.SelectedItem as NetGraph;

                    while ((selectedGraph == null) || (selectedGraph.CheckShutdown()))
                    {
                        PopulateConnections();

                        if (comboBoxConnection.Items.Count == 0)
                        {
                            selectedGraph = null;
                            break;
                        }

                        comboBoxConnection.SelectedItem = comboBoxConnection.Items[0];

                        selectedGraph = comboBoxConnection.SelectedItem as NetGraph;
                    }

                    if (selectedGraph != null)
                    {
                        if (logPacketControl.Packets.Length > 0)
                        {
                            if (comboBoxNodes.SelectedItem != null)
                            {
                                int repeatCount       = (int)numericRepeatCount.Value;
                                BasePipelineNode node = (BasePipelineNode)comboBoxNodes.SelectedItem;

                                LogPacket[] basePackets = checkBoxInjectSelected.Checked ? logPacketControl.SelectedPackets : logPacketControl.Packets;

                                List <LogPacket> packets = new List <LogPacket>();

                                for (int i = 0; i < repeatCount; ++i)
                                {
                                    packets.AddRange((LogPacket[])GeneralUtils.CloneObject(basePackets));
                                }

                                NetGraphBuilder builder = new NetGraphBuilder();

                                ClientEndpointFactory client = builder.AddClient("client", Guid.NewGuid());
                                ServerEndpointFactory server = builder.AddServer("server", Guid.NewGuid());
                                DynamicNodeFactory    dyn    = null;

                                BaseNodeFactory startNode = client;

                                if (_config.EnablePacketDelay && (_config.PacketDelayMs > 0))
                                {
                                    DelayNodeFactory delay = builder.AddNode(new DelayNodeFactory("delay", Guid.NewGuid())
                                    {
                                        PacketDelayMs = (int)_config.PacketDelayMs
                                    });
                                    builder.AddLine(startNode, delay, null);
                                    startNode = delay;
                                }

                                if (_config.EnableScripting && _config.ScriptDocumentId != Guid.Empty && !String.IsNullOrWhiteSpace(_config.ScriptDocumentClass))
                                {
                                    ScriptDocument doc = CANAPEProject.CurrentProject.GetDocumentByUuid(_config.ScriptDocumentId) as ScriptDocument;

                                    if (doc != null)
                                    {
                                        dyn = new DynamicNodeFactory("dyn", Guid.NewGuid(), doc.Container, _config.ScriptDocumentClass, null);

                                        builder.AddNode(dyn);
                                        builder.AddLine(startNode, dyn, null);
                                        startNode = dyn;
                                    }
                                }

                                builder.AddLine(startNode, server, null);

                                _injectGraph = builder.Factory.Create(selectedGraph.Logger, selectedGraph, selectedGraph.GlobalMeta,
                                                                      new MetaDictionary(), new PropertyBag("root"));

                                QueuedDataAdapter inputAdapter = new QueuedDataAdapter();
                                foreach (LogPacket p in packets)
                                {
                                    inputAdapter.Enqueue(p.Frame);
                                }
                                inputAdapter.StopEnqueue();

                                _injectGraph.BindEndpoint(client.Id, inputAdapter);


                                _injectGraph.BindEndpoint(server.Id, new DelegateDataAdapter(
                                                              () => this.CancelInject(),
                                                              frame => node.Input(frame),
                                                              null
                                                              ));

                                // Start injection
                                (_injectGraph.Nodes[client.Id] as IPipelineEndpoint).Start();

                                // Check if the dynamic node was an endpoint (so a generator), start as well
                                if ((dyn != null) && (_injectGraph.Nodes[dyn.Id] is PipelineEndpoint))
                                {
                                    (_injectGraph.Nodes[dyn.Id] as IPipelineEndpoint).Start();
                                }

                                // Start cancel timer
                                timerCancel.Start();

                                btnInject.Text = CANAPE.Properties.Resources.InjectPacketControl_CancelButtonText;
                            }
                            else
                            {
                                MessageBox.Show(this, CANAPE.Properties.Resources.InjectPacketForm_SelectNode,
                                                CANAPE.Properties.Resources.MessageBox_ErrorString, MessageBoxButtons.OK,
                                                MessageBoxIcon.Error);
                            }
                        }
                    }
                    else
                    {
                        MessageBox.Show(this, CANAPE.Properties.Resources.InjectPacketForm_SelectGraph,
                                        CANAPE.Properties.Resources.MessageBox_ErrorString, MessageBoxButtons.OK,
                                        MessageBoxIcon.Error);
                    }
                }
                catch (NotSupportedException)
                {
                    MessageBox.Show(this, CANAPE.Properties.Resources.InjectPacketForm_NotSupported,
                                    CANAPE.Properties.Resources.MessageBox_ErrorString, MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
                catch (InvalidOperationException ex)
                {
                    MessageBox.Show(this, ex.Message,
                                    CANAPE.Properties.Resources.MessageBox_ErrorString, MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
                catch (NodeFactoryException ex)
                {
                    MessageBox.Show(this, ex.Message,
                                    CANAPE.Properties.Resources.MessageBox_ErrorString, MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
            }
        }
예제 #9
0
 internal static IClientEndpoint Proxy(string path)
 {
     return(ClientEndpointFactory.Cast(GrainReference.FromKeyString(path)));
 }
예제 #10
0
 public void Dispose()
 {
     ClientEndpointFactory.DeleteObjectReference(proxy);
 }
예제 #11
0
 public Client(Assembly assembly, string address) : base(ClientEndpointFactory <T> .GetServiceEndpoint(assembly, address))
 {
 }
예제 #12
0
 public Client(Assembly assembly) : base(ClientEndpointFactory <T> .GetServiceEndpoint(assembly))
 {
 }
예제 #13
0
 public Client(string address) : base(ClientEndpointFactory <T> .GetServiceEndpoint(address))
 {
 }
예제 #14
0
 public Client() : base(ClientEndpointFactory <T> .GetServiceEndpoint())
 {
 }