public void Simple() { using (var context = NetMQContext.Create()) { ShimAction shimAction = shim => { shim.SignalOK(); while (true) { NetMQMessage msg = shim.ReceiveMultipartMessage(); string command = msg[0].ConvertToString(); if (command == NetMQActor.EndShimMessage) { break; } if (command == "Hello") { shim.SendFrame("World"); } } }; using (var actor = NetMQActor.Create(context, shimAction)) { actor.SendMoreFrame("Hello").SendFrame("Hello"); Assert.AreEqual("World", actor.ReceiveFrameString()); } } }
/// <summary> /// Create a new ActionShimHandler with the given type T to serve as the state-information, /// and the given action to operate upon that type. /// </summary> /// <param name="action">a ShimAction of type T that comprises the action to perform</param> /// <param name="state">the state-information</param> public ActionShimHandler(ShimAction <T> action, T state) { m_action = action; m_state = state; }
/// <summary> /// Create a new <see cref="NetMQActor"/> with the action, and state-information. /// </summary> /// <param name="action">a <c>ShimAction</c> - delegate for the action to perform</param> /// <param name="state">the state-information - of the generic type T</param> /// <returns>the newly-created <c>NetMQActor</c></returns> public static NetMQActor Create <T>(ShimAction <T> action, T state) { return(new NetMQActor(new PairSocket(), new PairSocket(), new ActionShimHandler <T>(action, state))); }
/// <summary> /// Create a new <see cref="NetMQActor"/> with the given <see cref="ShimAction"/>. /// </summary> /// <param name="action">a <c>ShimAction</c> - delegate for the action to perform</param> /// <returns>the newly-created <c>NetMQActor</c></returns> public static NetMQActor Create(ShimAction action) { return(new NetMQActor(new PairSocket(), new PairSocket(), new ActionShimHandler(action))); }
public static NetMQActor Create(NetMQContext context, ShimAction action) { return(new NetMQActor(context.CreatePairSocket(), context.CreatePairSocket(), new ActionShimHandler(action))); }
public static NetMQActor Create <T>(NetMQContext context, ShimAction <T> action, T state) { return(new NetMQActor(context.CreatePairSocket(), context.CreatePairSocket(), new ActionShimHandler <T>(action, state))); }
public static NetMQActor Create([NotNull] NetMQContext context, [NotNull] ShimAction action) { return(new NetMQActor(context, new ActionShimHandler(action))); }
public static NetMQActor Create <T>([NotNull] NetMQContext context, [NotNull] ShimAction <T> action, T state) { return(new NetMQActor(context, new ActionShimHandler <T>(action, state))); }
/// <summary> /// Create a new ActionShimHandler with the given type T to serve as the state-information, /// and the given action to operate upon that type. /// </summary> /// <param name="action">a ShimAction of type T that comprises the action to perform</param> /// <param name="state">the state-information</param> public ActionShimHandler([NotNull] ShimAction <T> action, T state) { this.m_action = action; this.m_state = state; }