Example #1
0
 public GraphEntry(LayerSectionFilter filter, LayerSectionDataAdapter clientAdapter,
                   LayerSectionDataAdapter serverAdapter, NetGraph graph, Guid clientEndpoint,
                   Guid serverEndpoint, NetworkLayerBinding defaultBinding)
 {
     Filter          = filter;
     _clientAdapter  = clientAdapter;
     _serverAdapter  = serverAdapter;
     Graph           = graph;
     _clientEndpoint = clientEndpoint;
     _serverEndpoint = serverEndpoint;
     _defaultBinding = defaultBinding;
 }
Example #2
0
 public GraphEntry(LayerSectionFilter filter, LayerSectionDataAdapter clientAdapter,
     LayerSectionDataAdapter serverAdapter, NetGraph graph, Guid clientEndpoint,
     Guid serverEndpoint, NetworkLayerBinding defaultBinding)
 {
     Filter = filter;
     _clientAdapter = clientAdapter;
     _serverAdapter = serverAdapter;
     Graph = graph;
     _clientEndpoint = clientEndpoint;
     _serverEndpoint = serverEndpoint;
     _defaultBinding = defaultBinding;
 }
Example #3
0
        private void HandleFrame(LayerSectionFilter filter, DataFrame frame)
        {
            string     name       = GenerateName(filter, frame);
            GraphEntry startEntry = null;

            lock (_graphEntries)
            {
                if (!_shuttingDown)
                {
                    if (_graphEntries.ContainsKey(name))
                    {
                        _graphEntries[name].GetInputAdapter(_direction).Enqueue(frame);
                    }
                    else
                    {
                        LayerSectionDataAdapter clientAdapter = new LayerSectionDataAdapter(this);
                        LayerSectionDataAdapter serverAdapter = new LayerSectionDataAdapter(_linkedNode);

                        if (_direction == LayerSectionGraphDirection.ClientToServer)
                        {
                            LayerSectionDataAdapter temp = clientAdapter;
                            clientAdapter = serverAdapter;
                            serverAdapter = temp;
                        }

                        var clients = filter.Factory.GetNodes <ClientEndpointFactory>();
                        var servers = filter.Factory.GetNodes <ServerEndpointFactory>();

                        if ((clients.Length > 0) && (servers.Length > 0))
                        {
                            MetaDictionary meta = filter.IsolatedGraph ? new MetaDictionary() : Graph.Meta;

                            NetGraph graph = filter.Factory.Create(Graph.Logger, Graph, Graph.GlobalMeta, meta, Graph.ConnectionProperties.AddBag(name));
                            graph.Name = String.Format(CultureInfo.InvariantCulture, "{0}.{1}", Name, name);
                            startEntry = new GraphEntry(filter, clientAdapter, serverAdapter,
                                                        graph, clients[0].Id, servers[0].Id, ProxyNetworkService.GetLayerBinding(Graph));
                            startEntry.GetInputAdapter(_direction).Enqueue(frame);

                            _graphEntries[name] = startEntry;
                        }
                        else
                        {
                            throw new ArgumentException(CANAPE.Net.Properties.Resources.LayerSectionNode_InvalidGraph);
                        }
                    }
                }
            }

            // Ensure this is done outside the lock
            if (startEntry != null)
            {
                startEntry.NegotiationThread = new Thread(() =>
                {
                    try
                    {
                        startEntry.Start();
                    }
                    catch (Exception ex)
                    {
                        Graph.Logger.LogException(ex);
                        lock (_graphEntries)
                        {
                            _graphEntries.Remove(name);
                            startEntry.Dispose();
                        }
                    }
                }
                                                          );
                startEntry.NegotiationThread.CurrentUICulture = Thread.CurrentThread.CurrentUICulture;
                startEntry.NegotiationThread.IsBackground     = true;
                startEntry.NegotiationThread.Start();
            }
        }
Example #4
0
        private void HandleFrame(LayerSectionFilter filter, DataFrame frame)
        {
            string name = GenerateName(filter, frame);
            GraphEntry startEntry = null;

            lock (_graphEntries)
            {
                if (!_shuttingDown)
                {
                    if (_graphEntries.ContainsKey(name))
                    {
                        _graphEntries[name].GetInputAdapter(_direction).Enqueue(frame);
                    }
                    else
                    {
                        LayerSectionDataAdapter clientAdapter = new LayerSectionDataAdapter(this);
                        LayerSectionDataAdapter serverAdapter = new LayerSectionDataAdapter(_linkedNode);

                        if (_direction == LayerSectionGraphDirection.ClientToServer)
                        {
                            LayerSectionDataAdapter temp = clientAdapter;
                            clientAdapter = serverAdapter;
                            serverAdapter = temp;
                        }

                        var clients = filter.Factory.GetNodes<ClientEndpointFactory>();
                        var servers = filter.Factory.GetNodes<ServerEndpointFactory>();

                        if ((clients.Length > 0) && (servers.Length > 0))
                        {
                            MetaDictionary meta = filter.IsolatedGraph ? new MetaDictionary() : Graph.Meta;

                            NetGraph graph = filter.Factory.Create(Graph.Logger, Graph, Graph.GlobalMeta, meta, Graph.ConnectionProperties.AddBag(name));
                            graph.Name = String.Format(CultureInfo.InvariantCulture, "{0}.{1}", Name, name);
                            startEntry = new GraphEntry(filter, clientAdapter, serverAdapter,
                                graph, clients[0].Id, servers[0].Id, ProxyNetworkService.GetLayerBinding(Graph));
                            startEntry.GetInputAdapter(_direction).Enqueue(frame);

                            _graphEntries[name] = startEntry;
                        }
                        else
                        {
                            throw new ArgumentException(CANAPE.Net.Properties.Resources.LayerSectionNode_InvalidGraph);
                        }
                    }
                }
            }

            // Ensure this is done outside the lock
            if (startEntry != null)
            {
                startEntry.NegotiationThread = new Thread(() =>
                {
                    try
                    {
                        startEntry.Start();
                    }
                    catch (Exception ex)
                    {
                        Graph.Logger.LogException(ex);
                        lock (_graphEntries)
                        {
                            _graphEntries.Remove(name);
                            startEntry.Dispose();
                        }
                    }
                }
                );
                startEntry.NegotiationThread.CurrentUICulture = Thread.CurrentThread.CurrentUICulture;
                startEntry.NegotiationThread.IsBackground = true;
                startEntry.NegotiationThread.Start();
            }
        }