static void Main(string[] args)
{
using (NetMQContext context = NetMQContext.Create())
{
using (WSRouter router = context.CreateWSRouter())
using (WSPublisher publisher = context.CreateWSPublisher())
{
router.Bind("ws://localhost:80");
publisher.Bind("ws://localhost:81");
router.ReceiveReady += (sender, eventArgs) =>
{
string identity = router.ReceiveString();
string message = router.ReceiveString();
router.SendMore(identity).Send("OK");
publisher.SendMore("chat").Send(message);
};
Poller poller = new Poller();
poller.AddSocket(router);
// we must add the publisher to the poller although we are not registering to any event.
// The internal stream socket handle connections and subscriptions and use the events internally
poller.AddSocket(publisher);
poller.Start();
}
}
}