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(); }
/// <summary> /// Creates a new IncomingDataMessage object from a NGRIDDataTransferMessage object. /// </summary> /// <param name="client">Reference to the NGRIDClient object</param> /// <param name="message">NGRIDDataTransferMessage object to create IncomingDataMessage</param> public IncomingDataMessage(NGRIDClient client, NGRIDDataTransferMessage message) { _client = client; DestinationApplicationName = message.DestinationApplicationName; DestinationCommunicatorId = message.DestinationCommunicatorId; DestinationServerName = message.DestinationServerName; MessageData = message.MessageData; MessageId = message.MessageId; PassedServers = message.PassedServers; RepliedMessageId = message.RepliedMessageId; SourceApplicationName = message.SourceApplicationName; SourceCommunicatorId = message.SourceCommunicatorId; SourceServerName = message.SourceServerName; TransmitRule = message.TransmitRule; }
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 OutgoingDataMessage object. /// </summary> /// <param name="client">Reference to the NGRIDClient object</param> public OutgoingDataMessage(NGRIDClient client) { _client = client; }