コード例 #1
0
        /// <summary>
        /// Run the tutorial.
        /// </summary>
        public void Run()
        {
            // graph1 -> *SerializerArrow -> UDPMulticastSenderArrow ==[IP MULTICAST]=> UDPMulticastReceiverArrow -> -> graph2

            // Create two independend graphs
            var graph1 = GraphFactory.CreateGenericPropertyGraph(1);
            var graph2 = GraphFactory.CreateGenericPropertyGraph(2);


            // Create an arrow sending all messages to UDP multicast
            var UDPMulticastSenderArrow = new UDPMulticastSenderArrow <String>("224.100.0.1", IPPort.Parse(9001));

            var GraphSerializer       = graph1.NewGraphMLSerializer(IncludePropertyTypes: true);
            var VertexSerializerArrow = GraphSerializer.NewVertexSerializerArrow(UDPMulticastSenderArrow);
            var EdgeSerializerArrow   = GraphSerializer.NewEdgeSerializerArrow(UDPMulticastSenderArrow);
            var GraphSerializerArrow  = GraphSerializer.NewGraphSerializerArrow(UDPMulticastSenderArrow);


            // Connect the graph1 vertex/edge added events to the serializers
            //graph1.OnVertexAdded += VertexSerializerArrow.ReceiveMessage;
            //graph1.OnEdgeAdded   +=   EdgeSerializerArrow.ReceiveMessage;


            // Create an arrow receiving messages from UDP multicast
            var UDPMulticastReceiverArrow = new UDPMulticastReceiverArrow <String>("224.100.0.1", IPPort.Parse(9001));

            UDPMulticastReceiverArrow.OnMessageAvailable += (Sender, Message) => Console.WriteLine(Sender.Address + ":" + Sender.Port + " => " + Message);


            // Populate the graph
            var v1 = graph1.AddVertex(v => v.SetProperty("graph", 1));
            var v2 = graph1.AddVertex(v => v.SetProperty("graph", 1));
            var v3 = graph1.AddVertex(v => v.SetProperty("graph", "1"));
            var v4 = graph1.AddVertex(v => v.SetProperty("graph", "2"));

            var e1 = graph1.AddEdge(v1, "links", v2, e => e.SetProperty("weight", 0.34));
            var e2 = graph1.AddEdge(v2, "links", v3);

            GraphSerializerArrow.ReceiveMessage(graph1);

            while (true)
            {
                Thread.Sleep(100);
            }
        }
コード例 #2
0
ファイル: MulticastDemo.cs プロジェクト: Vanaheimr/Bragi
        /// <summary>
        /// Run the tutorial.
        /// </summary>
        public void Run()
        {
            // graph1 -> *SerializerArrow -> UDPMulticastSenderArrow ==[IP MULTICAST]=> UDPMulticastReceiverArrow -> -> graph2

            // Create two independend graphs
            var graph1 = GraphFactory.CreateGenericPropertyGraph(1);
            var graph2 = GraphFactory.CreateGenericPropertyGraph(2);

            // Create an arrow sending all messages to UDP multicast
            var UDPMulticastSenderArrow   = new UDPMulticastSenderArrow<String>("224.100.0.1", IPPort.Parse(9001));

            var GraphSerializer           = graph1.NewGraphMLSerializer(IncludePropertyTypes: true);
            var VertexSerializerArrow     = GraphSerializer.NewVertexSerializerArrow(UDPMulticastSenderArrow);
            var EdgeSerializerArrow       = GraphSerializer.NewEdgeSerializerArrow  (UDPMulticastSenderArrow);
            var GraphSerializerArrow      = GraphSerializer.NewGraphSerializerArrow (UDPMulticastSenderArrow);

            // Connect the graph1 vertex/edge added events to the serializers
            //graph1.OnVertexAdded += VertexSerializerArrow.ReceiveMessage;
            //graph1.OnEdgeAdded   +=   EdgeSerializerArrow.ReceiveMessage;

            // Create an arrow receiving messages from UDP multicast
            var UDPMulticastReceiverArrow = new UDPMulticastReceiverArrow<String>("224.100.0.1", IPPort.Parse(9001));
            UDPMulticastReceiverArrow.OnMessageAvailable += (Sender, Message) => Console.WriteLine(Sender.Address + ":" + Sender.Port + " => " + Message);

            // Populate the graph
            var v1 = graph1.AddVertex(v => v.SetProperty("graph", 1));
            var v2 = graph1.AddVertex(v => v.SetProperty("graph", 1));
            var v3 = graph1.AddVertex(v => v.SetProperty("graph", "1"));
            var v4 = graph1.AddVertex(v => v.SetProperty("graph", "2"));

            var e1 = graph1.AddEdge  (v1, "links", v2, e => e.SetProperty("weight", 0.34));
            var e2 = graph1.AddEdge  (v2, "links", v3);

            GraphSerializerArrow.ReceiveMessage(graph1);

            while (true)
            {
                Thread.Sleep(100);
            }
        }