/* Copyright 1999-2011 (c) My-Channels Copyright (c) 2012-2014 Software AG, Darmstadt, Germany and/or Software AG USA Inc., Reston, VA, USA, and/or its subsidiaries and/or its affiliates and/or their licensors. Use, reproduction, transfer, publication or disclosure is prohibited except as specifically provided for in your License Agreement with Software AG. */ using System; using System.Collections.Generic; using System.Linq; using System.Text; namespace MyChannels.Nirvana.Samples { /// /// This is an example of how RX entensions to the .Net extended API enables integration with the Reactive Framework from Microsoft /// public class RXDataGroupListener { // the url of the Nirvana realm private string url; /// /// Pass the rname url of the realm /// /// rname of the realm public RXDataGroupListener(string rname) { url = rname; start(); } /// /// Initialise the Session object and set up the Observale query /// private void start() { using (var session = new Session(url)) { // Enable DataGroup delivery session.DataGroups.Enable = true; // Query each message // NOTE: you must be referencing the Rx framework for this to build! var query = from e in session.DataGroups.ToObservable() select e.Message; // Subscribe query.Subscribe(ProcessMessage); // Initialize the session session.Initialize(); // Wait for input from the console, exit on key entry Console.ReadLine(); Console.WriteLine("Exiting the application"); } } /// /// Deal with the message /// /// public void ProcessMessage(Object m) { Console.WriteLine("Message :" + ((Message)m).Id); } static void Main(string[] args) { new RXDataGroupListener(args[0]); } } }