-
Notifications
You must be signed in to change notification settings - Fork 6
How To
Tommaso Bertoni edited this page Dec 23, 2016
·
6 revisions
- Create and start a server:
IrisServer server = new IrisServer();
server.Start(2200); // Start on port 2200
- Create and connect a local node:
// 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());
IrisServerLocalNode node = new IrisServerLocalNode();
node.Connect(config);
- Create and connect a network node:
IrisClientConfig config = new IrisClientConfig() { Hostname = "127.0.0.1", Port = 2200 };
IrisClientNode node = new IrisClientNode();
node.Connect(config);
- Subscribe to a channel
IDisposableSubscription subscription = node.Subscribe("worldnews", MyContentHandler);
- Send a message
node.Send("worldnews", "something good happened");
- Unsubscribe from a channel
// 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
node.Unsubscribe("worldnews", MyContentHandler);
For more examples and use cases head over to the *[Iris.NET.Demo project](https://github.com/tommasobertoni/Iris.NET/tree/master/Iris.NET.Demo/Iris.NET.Demo)*.