static void Main() { //Create NGRIDClient object to connect to NGRID //Name of this application: ProducerSample var ngridClient = new NGRIDClient("ProducerSample"); //Connect to NGRID server ngridClient.Connect(); Console.WriteLine("Enter text to be sent to consumer sample."); while (true) { //Get a message from user var messageText = Console.ReadLine(); if (string.IsNullOrEmpty(messageText) || messageText == "exit") { break; } //Create a NGRID Message to send to ConsumerSample var message = ngridClient.CreateMessage(); //Set destination application name message.DestinationApplicationName = "ConsumerSample"; //message.DestinationServerName = "someserver"; //Set message data message.MessageData = Encoding.UTF8.GetBytes(messageText); //Send message message.Send(); } //Disconnect from NGRID server ngridClient.Disconnect(); }
static void Main(string[] args) { //Create NGRIDClient object to connect to NGRID //Name of this application: ConsumerSample var ngridClient = new NGRIDClient("ConsumerSample"); //Register to MessageReceived event to get messages. ngridClient.MessageReceived += NGRIDClient_MessageReceived; //Connect to NGRID server ngridClient.Connect(); //Wait user to press enter to terminate application Console.WriteLine("hit enter to quit..."); Console.ReadLine(); //Disconnect from NGRID server ngridClient.Disconnect(); }
/// <summary> /// Creates a new NGRIDServiceApplication object. /// </summary> /// <param name="applicationName">Name of the application</param> /// <param name="ipAddress">IP address of NGRID server</param> /// <param name="port">TCP port of NGRID server</param> public NGRIDServiceConsumer(string applicationName, string ipAddress, int port) { NgridClient = new NGRIDClient(applicationName, ipAddress, port); }
/// <summary> /// Creates a new NGRIDServiceApplication object with default port to connect to NGRID server. /// </summary> /// <param name="applicationName">Name of the application</param> /// <param name="ipAddress">IP address of NGRID server</param> public NGRIDServiceConsumer(string applicationName, string ipAddress) { NgridClient = new NGRIDClient(applicationName, ipAddress, CommunicationConsts.DefaultNGRIDPort); }
/// <summary> /// Creates a new NGRIDServiceApplication object with default values to connect to NGRID server. /// </summary> /// <param name="applicationName">Name of the application</param> public NGRIDServiceConsumer(string applicationName) { NgridClient = new NGRIDClient(applicationName, CommunicationConsts.DefaultIpAddress, CommunicationConsts.DefaultNGRIDPort); Initialize(); }
/// <summary> /// Creates a new NGRIDServiceApplication object. /// </summary> /// <param name="applicationName">Name of the application</param> /// <param name="ipAddress">IP address of NGRID server</param> /// <param name="port">TCP port of NGRID server</param> public NGRIDServiceApplication(string applicationName, string ipAddress, int port) { _ngridClient = new NGRIDClient(applicationName, ipAddress, port); Initialize(); }
/// <summary> /// Creates a new NGRIDServiceApplication object with default port to connect to NGRID server. /// </summary> /// <param name="applicationName">Name of the application</param> /// <param name="ipAddress">IP address of NGRID server</param> public NGRIDServiceApplication(string applicationName, string ipAddress) { _ngridClient = new NGRIDClient(applicationName, ipAddress, CommunicationConsts.DefaultNGRIDPort); Initialize(); }