-
Notifications
You must be signed in to change notification settings - Fork 15
Expand file tree
/
Copy pathProgram.cs
More file actions
54 lines (42 loc) · 992 Bytes
/
Program.cs
File metadata and controls
54 lines (42 loc) · 992 Bytes
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
42
43
44
45
46
47
48
49
50
51
52
53
54
using System;
using System.Threading;
using ProtoBuf;
namespace NetMQ.ReactiveExtensions.SampleSubscriber
{
class Program
{
static void Main(string[] args)
{
Console.Write("Reactive Extensions subscriber demo:\n");
string endPoint = "tcp://127.0.0.1:56001";
if (args.Length >= 1)
{
endPoint = args[0];
}
Console.Write("Endpoint: {0}\n", endPoint);
SubscriberNetMq<MyMessage> subject = new SubscriberNetMq<MyMessage>(endPoint, loggerDelegate: msg => Console.Write(msg));
subject.Subscribe(message =>
{
Console.Write("Received: {0}, '{1}'.\n", message.Num, message.Name);
});
Console.WriteLine("[waiting for publisher - any key to exit]");
Console.ReadKey();
}
}
[ProtoContract]
public class MyMessage
{
public MyMessage()
{
}
public MyMessage(int num, string name)
{
Num = num;
Name = name;
}
[ProtoMember(1)]
public int Num { get; set; }
[ProtoMember(2)]
public string Name { get; set; }
}
}