예제 #1
0
        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();
        }
예제 #2
0
        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();
        }