@@ -8,16 +8,16 @@ class RPCServer
8
8
public static void Main ( )
9
9
{
10
10
var factory = new ConnectionFactory ( ) { HostName = "localhost" } ;
11
- using ( var connection = factory . CreateConnection ( ) )
12
- using ( var channel = connection . CreateModel ( ) )
11
+ using ( var connection = factory . CreateConnection ( ) )
12
+ using ( var channel = connection . CreateModel ( ) )
13
13
{
14
- channel . QueueDeclare ( queue : "rpc_queue" , durable : false , exclusive : false , autoDelete : false , arguments : null ) ;
15
- channel . BasicQos ( 0 , 1 , false ) ;
16
- var consumer = new QueueingBasicConsumer ( channel ) ;
17
- channel . BasicConsume ( queue : "rpc_queue" , noAck : false , consumer : consumer ) ;
18
- Console . WriteLine ( " [x] Awaiting RPC requests" ) ;
14
+ channel . QueueDeclare ( queue : "rpc_queue" , durable : false , exclusive : false , autoDelete : false , arguments : null ) ;
15
+ channel . BasicQos ( 0 , 1 , false ) ;
16
+ var consumer = new QueueingBasicConsumer ( channel ) ;
17
+ channel . BasicConsume ( queue : "rpc_queue" , noAck : false , consumer : consumer ) ;
18
+ Console . WriteLine ( " [x] Awaiting RPC requests" ) ;
19
19
20
- while ( true )
20
+ while ( true )
21
21
{
22
22
string response = null ;
23
23
var ea = ( BasicDeliverEventArgs ) consumer . Queue . Dequeue ( ) ;
@@ -29,21 +29,21 @@ public static void Main()
29
29
30
30
try
31
31
{
32
- var message = Encoding . UTF8 . GetString ( body ) ;
33
- int n = int . Parse ( message ) ;
34
- Console . WriteLine ( " [.] fib({0})" , message ) ;
35
- response = fib ( n ) . ToString ( ) ;
32
+ var message = Encoding . UTF8 . GetString ( body ) ;
33
+ int n = int . Parse ( message ) ;
34
+ Console . WriteLine ( " [.] fib({0})" , message ) ;
35
+ response = fib ( n ) . ToString ( ) ;
36
36
}
37
- catch ( Exception e )
37
+ catch ( Exception e )
38
38
{
39
- Console . WriteLine ( " [.] " + e . Message ) ;
39
+ Console . WriteLine ( " [.] " + e . Message ) ;
40
40
response = "" ;
41
41
}
42
42
finally
43
43
{
44
- var responseBytes = Encoding . UTF8 . GetBytes ( response ) ;
45
- channel . BasicPublish ( exchange : "" , routingKey : props . ReplyTo , basicProperties : replyProps , body : responseBytes ) ;
46
- channel . BasicAck ( deliveryTag : ea . DeliveryTag , multiple : false ) ;
44
+ var responseBytes = Encoding . UTF8 . GetBytes ( response ) ;
45
+ channel . BasicPublish ( exchange : "" , routingKey : props . ReplyTo , basicProperties : replyProps , body : responseBytes ) ;
46
+ channel . BasicAck ( deliveryTag : ea . DeliveryTag , multiple : false ) ;
47
47
}
48
48
}
49
49
}
@@ -53,13 +53,13 @@ public static void Main()
53
53
/// Assumes only valid positive integer input.
54
54
/// Don't expect this one to work for big numbers, and it's probably the slowest recursive implementation possible.
55
55
/// </summary>
56
- private static int fib ( int n )
56
+ private static int fib ( int n )
57
57
{
58
- if ( n == 0 || n == 1 )
58
+ if ( n == 0 || n == 1 )
59
59
{
60
60
return n ;
61
61
}
62
62
63
- return fib ( n - 1 ) + fib ( n - 2 ) ;
63
+ return fib ( n - 1 ) + fib ( n - 2 ) ;
64
64
}
65
65
}
0 commit comments