コード例 #1
0
        private static async void Commands_Sending_Command_Request_async()
        {
            string ChannelName         = "testing_command_channel",
                   ClientID            = "hello-world-sender",
                   KubeMQServerAddress = "localhost:50000";

            var channel = new KubeMQ.SDK.csharp.CommandQuery.Channel(new KubeMQ.SDK.csharp.CommandQuery.ChannelParameters {
                RequestsType  = KubeMQ.SDK.csharp.CommandQuery.RequestType.Command,
                Timeout       = 1000,
                ChannelName   = ChannelName,
                ClientID      = ClientID,
                KubeMQAddress = KubeMQServerAddress,
                AuthToken     = tempAuthToken
            });

            try {
                var result = await channel.SendRequestAsync(new KubeMQ.SDK.csharp.CommandQuery.Request {
                    Body = KubeMQ.SDK.csharp.Tools.Converter.ToByteArray("hello kubemq - sending a command, please reply")
                });

                if (!result.Executed)
                {
                    Console.WriteLine($"Response error:{result.Error}");
                    return;
                }
                Console.WriteLine($"Response Received:{result.RequestID} ExecutedAt:{result.Timestamp}");
            } catch (Exception ex) {
                Console.WriteLine(ex.Message);
            }
        }
コード例 #2
0
        static void Main(string[] args)
        {
            var ChannelName         = "testing_RPC_channel";
            var ClientID            = "hello-world-sender";
            var KubeMQServerAddress = "localhost:50000";

            var channel = new KubeMQ.SDK.csharp.CommandQuery.Channel(new KubeMQ.SDK.csharp.CommandQuery.ChannelParameters
            {
                RequestsType  = KubeMQ.SDK.csharp.CommandQuery.RequestType.Command,
                Timeout       = 10000,
                ChannelName   = ChannelName,
                ClientID      = ClientID,
                KubeMQAddress = KubeMQServerAddress
            });

            try
            {
                var result = channel.SendRequest(new KubeMQ.SDK.csharp.CommandQuery.Request
                {
                    Body = KubeMQ.SDK.csharp.Tools.Converter.ToByteArray("hello kubemq - sending a command, please reply")
                });

                if (!result.Executed)
                {
                    Console.WriteLine($"Response error:{result.Error}");
                    return;
                }
                Console.WriteLine($"Response Received:{result.RequestID} ExecutedAt:{result.Timestamp}");
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.Message);
            }
        }