コード例 #1
0
        public static void Execute()
        {
            // Subscribe to transactions event
            // see https://docs.iota.org/docs/iri/0.1/references/zmq-events for all events
            ZmqIriListener.Transactions += (sender, eventArgs) =>
            {
                Console.WriteLine("-----------------------");
                Console.WriteLine(eventArgs.Transaction.Hash);
                Console.WriteLine(eventArgs.Transaction.Address);
            };

            // start listening to the event type (use MessageType.All) to subscribe to all events
            var tokenSource = ZmqIriListener.Listen("tcp://trinity.iota-tangle.io:5556", MessageType.Transactions);

            // listen for 60 seconds
            var stopwatch = new Stopwatch();

            stopwatch.Start();

            while (stopwatch.ElapsedMilliseconds < 600000)
            {
                Thread.Sleep(100);
            }

            // cancel the thread
            tokenSource.Cancel();
        }
コード例 #2
0
        public static void ZMQTest()
        {
            // Subscribe to transactions event
            ZmqIriListener.Transactions += (sender, eventArgs) =>
            {
                Console.WriteLine("-----------------------");
                Console.WriteLine(eventArgs.Transaction.Hash);
                Console.WriteLine(eventArgs.Transaction.Address);
            };

            // Start listening to the event type (use MessageType.All) to subscribe to all events
            var tokenSource = ZmqIriListener.Listen("tcp://node_url", MessageType.Transactions);

            // Listen for 60 seconds
            var stopwatch = new Stopwatch();

            stopwatch.Start();
            while (stopwatch.ElapsedMilliseconds < 600000)
            {
                Thread.Sleep(100);
            }
            // Cancel the thread
            tokenSource.Cancel();
        }