/* * * Copyright (c) 1999 - 2011 my-Channels Ltd * Copyright (c) 2012 - 2017 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 to use the .Net extended API for Data Groups /// public class ExDataGroupListener { // the url of the Nirvana realm private string url; /// /// Pass the rname url of the realm /// /// rname of the realm public ExDataGroupListener(string rname) { url = rname; start(); } /// /// Initialise the Session object /// private void start() { using (var session = new Session(url)) { // Enable DataGroup delivery session.DataGroups.Enable = true; // Messages are not buffered, and you don't want to miss any! session.DataGroups.MessageReceived += (s, e) => ProcessMessage(e.Message); // 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 ExDataGroupListener(args[0]); } } }