-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathProgram.cs
More file actions
41 lines (33 loc) · 1.89 KB
/
Program.cs
File metadata and controls
41 lines (33 loc) · 1.89 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
using System;
using System.Threading.Tasks;
namespace RabbitMQ_Test
{
class Program
{
static void Main(string[] args)
{
Console.WriteLine("RPC Client");
Task t = InvokeAsync();
t.Wait();
Console.WriteLine(" Press [enter] to exit.");
Console.ReadLine();
}
private static async Task InvokeAsync()
{
var rpcClient = new ClientRPCRabbitMQWrapper("localhost");
Console.WriteLine(" [x] Requesting TestMethod");
var response = await rpcClient.CallAsync<string>(new RPCRequest() { Class = "RabbitMQ_Server.Test", Method = "TestMethod" });
Console.WriteLine(" [.] Got '{0}'", response);
Console.WriteLine(" [x] Requesting TestMethodObject");
var responseObject = await rpcClient.CallAsync<RPCObjectReturn>(new RPCRequest() { Class = "RabbitMQ_Server.Test", Method = "TestMethodObject" });
Console.WriteLine(" [.] Got '{0}'", (responseObject as RPCObjectReturn).MyProperty);
Console.WriteLine(" [x] Requesting TestMethodObjectwithParam");
var responseObjectWP = await rpcClient.CallAsync<RPCObjectReturn>(new RPCRequest() { Class = "RabbitMQ_Server.Test", Method = "TestMethodObjectwithParam", ParamsMethod = new object[] { 2 } });
Console.WriteLine(" [.] Got '{0}'", (responseObjectWP as RPCObjectReturn).MyProperty);
Console.WriteLine(" [x] Requesting TestMethodObjectwithParamAndConstructorParam");
var responseObjectCWP = await rpcClient.CallAsync<RPCObjectReturn>(new RPCRequest() { Class = "RabbitMQ_Server.Test", Method = "TestMethodObjectwithParam", ParamsMethod = new object[] { 3 }, ParamsConstructor = new object[] { 3 } });
Console.WriteLine(" [.] Got '{0}'", (responseObjectCWP as RPCObjectReturn).MyProperty);
rpcClient.Close();
}
}
}