/* * * 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; namespace MyChannels.Nirvana.Samples { class ExDataGroupPublisher { private string rName = null; private string groupName = null; public ExDataGroupPublisher(string[] args) { // Check arguments: if (args.Length < 1) { Console.WriteLine("realm name required"); Environment.Exit(2); } rName = args[0]; groupName = args[1]; start(); } private void start() { var session = new Session(rName); session.DataGroups.EnableAdmin = true; // Initialize the session session.Initialize(); Console.WriteLine("Initialized..."); var defaultGrp = session.DataGroups.Root; var dataGroupsSession = session.DataGroups; var dataGroups = dataGroupsSession.Root.Children; // ensure that any streams listening are added to all groups foreach (IDataStream stream in defaultGrp.Streams) { foreach (IDataGroup dg in dataGroups) { dg.AddStream(stream); } } // Publish to group var Producer = dataGroupsSession.CreateProducer(groupName); for (int i = 0; i < 10; ++i) { string msg = groupName + ": " + i; Producer.Send(new Message(msg, new byte[] {})); } // wait for key press before closing Console.ReadLine(); session.Dispose(); } static void Main(string[] args) { new ExDataGroupPublisher(args); } } }