-
Notifications
You must be signed in to change notification settings - Fork 6
How To
Tommaso Bertoni edited this page Mar 11, 2017
·
6 revisions
IrisServer server = new IrisServer();
server.Start(2200); // Start on port 2200
// If you have a server and you want to use the same subscription network
IrisServerConfig config = server.GetServerConfig();
// If you just want to communicate locally or on a different local network
IrisServerConfig config = new IrisServerConfig(new IrisPubSubRouter());
IrisLocalNode node = new IrisLocalNode();
node.Connect(config);
IrisClientConfig config = new IrisClientConfig() { Hostname = "127.0.0.1", Port = 2200 };
IrisClientNode node = new IrisClientNode();
node.Connect(config);
Task<IDisposableSubscription> asyncSubscriptionRequest = node.Subscribe("worldnews", MyContentHandler);
// The task is resolved when the subscription request is sent over the network stream
IDisposableSubscription subscription = await asyncSubscriptionRequest;
await node.Publish("worldnews", "something good happened");
// If you have a reference to the IDisposableSubscription returned by the
// Subscribe method you can simply write
subscription.Dispose();
// Otherwise you can use the Unsubscribe method
await node.Unsubscribe("worldnews", MyContentHandler);
For more examples and use cases head over to the Iris.NET.Demo project.