Ejemplo n.º 1
0
        static void Main(string[] args)
        {
            log4net.Config.XmlConfigurator.Configure();

            var ctx = ContextRegistry.GetContext();
            var clientConfig = (ClientConfig)ctx["ClientConfig"];

            // Create a client.
            Client client = new Client(clientConfig);

            // Attempt to connect.
            try
            {
                client.Connect();
            }
            catch (Exception ex)
            {
                Console.WriteLine("Failed to connect to distributor: {0}", ex.Message);
                Environment.Exit(-1);
            }

            // Create some data.
            var data = new Dictionary<string, object>()
            {
                { "NAME", "Vodafone Group PLC" },
                { "BID", 140.60 },
                { "ASK", 140.65 }
            };

            // Publish the data.
            client.Publish("LSE.VOD", true, data);

            // Close the client.
            client.Close();
        }
Ejemplo n.º 2
0
        static void Main(string[] args)
        {
            log4net.Config.XmlConfigurator.Configure();

            var ctx = ContextRegistry.GetContext();
            var clientConfig = (ClientConfig)ctx["ClientConfig"];

            // Create a client.
            var client = new Client(clientConfig);

            try
            {
                // Assume the Distributor is running on the local machine.
                client.Connect();
            }
            catch (Exception ex)
            {
                Console.WriteLine("Failed to connect to distributor: {0}", ex.Message);
                Environment.Exit(-1);
            }

            // Add a delegate to be called should the client be closed.
            client.OnClosed += OnClosed;
            // Add a delegate to be called when data arrives.
            client.OnData += OnData;

            // Subscribe to some topics.
            client.AddSubscription("LSE.VOD");
            client.AddSubscription("LSE.TSCO");
            client.AddSubscription("LSE.FOO");
            client.AddSubscription("VTX.BAY");

            // Wait to exit.
            Console.WriteLine("Press <enter> to quit");
            Console.ReadLine();

            // Tidy up.
            client.Close();
        }