/// <summary> /// Create a new NetMQBeacon, contained within the given context. /// </summary> /// <param name="context">the NetMQContext to contain this new socket</param> public NetMQBeacon([NotNull] NetMQContext context) { m_actor = NetMQActor.Create(context, new Shim()); m_receiveEventHelper = new EventDelegatorHelper<NetMQBeaconEventArgs>( () => m_actor.ReceiveReady += OnReceiveReady, () => m_actor.ReceiveReady -= OnReceiveReady); }
public Actor(NetMQContext context, IShimHandler <T> shimHandler, T state) { this.m_self = context.CreatePairSocket(); this.m_shim = new Shim <T>(shimHandler, context.CreatePairSocket()); this.m_self.Options.SendHighWatermark = 1000; this.m_self.Options.SendHighWatermark = 1000; this.m_state = state; m_receiveEventDelegatorHelper = new EventDelegatorHelper <NetMQActorEventArgs <T> >(() => m_self.ReceiveReady += OnReceive, () => m_self.ReceiveReady += OnReceive); m_sendEventDelegatorHelper = new EventDelegatorHelper <NetMQActorEventArgs <T> >(() => m_self.SendReady += OnReceive, () => m_self.SendReady += OnSend); //now binding and connect pipe ends string endPoint = string.Empty; while (true) { Action bindAction = () => { endPoint = GetEndPointName(); m_self.Bind(endPoint); }; try { bindAction(); break; } catch (NetMQException nex) { if (nex.ErrorCode == ErrorCode.EFAULT) { bindAction(); } } } m_shim.Pipe.Connect(endPoint); //Initialise the shim handler this.m_shim.Handler.Initialise(state); //Create Shim thread handler CreateShimThread(state); // Mandatory handshake for new actor so that constructor returns only // when actor has also initialized. This eliminates timing issues at // application start up. m_self.WaitForSignal(); }