Esempio n. 1
0
        public void Simple()
        {
            using (var context = NetMQContext.Create())
            {
                using (NetMQActor actor = NetMQActor.Create(context, shim =>
                {
                    shim.SignalOK();

                    while (true)
                    {
                        NetMQMessage msg = shim.ReceiveMessage();

                        string command = msg[0].ConvertToString();

                        if (command == NetMQActor.EndShimMessage)
                        {
                            break;
                        }

                        else if (command == "Hello")
                        {
                            shim.Send("World");
                        }
                    }
                }))
                {
                    actor.SendMore("Hello");
                    actor.Send("Hello");
                    var result = actor.ReceiveString();
                    Assert.AreEqual("World", result);
                }
            }
        }
Esempio n. 2
0
        public ReliableServer(string address)
        {
            m_address = address;

            // actor is like thread with builtin pair sockets connect the user thread with the actor thread
            m_actor = NetMQActor.Create(Run);
        }
Esempio n. 3
0
        /// <summary>
        /// Create reliable client
        /// </summary>
        /// <param name="context"></param>
        /// <param name="addresses">addresses of the reliable servers</param>
        public ReliableClient(NetMQContext context, params string[] addresses)
        {
            m_context   = context;
            m_addresses = addresses;

            m_actor = NetMQActor.Create(context, Run);
        }
Esempio n. 4
0
File: Zyre.cs Progetto: NetMQ/Zyre
        /// <summary>
        /// Create a Zyre API that communicates with a node on the ZRE bus.
        /// </summary>
        /// <param name="name">The name of the node</param>
        /// <param name="useEvents">Set this to true to disable Receive() and instead subscribe to events for getting messages from peers. Default is true.</param>
        /// <param name="loggerDelegate">An action to take for logging when _verbose is true. Default is null.</param>
        public Zyre (string name, bool useEvents = true, Action<string> loggerDelegate = null)
        {
            _useEvents = useEvents;
            // Create front-to-back pipe pair for data traffic
            // outbox is passed to ZyreNode for sending Zyre message traffic back to _inbox
            PairSocket outbox;
            PairSocket.CreateSocketPair(out outbox, out _inbox);

            // Start node engine and wait for it to be ready
            // All node control is done through _actor

            _actor = ZyreNode.Create(outbox, loggerDelegate);

            if (useEvents)
            {
                _inboxPoller = new NetMQPoller();
                _inbox.ReceiveReady += InboxReceiveReady;
                _inboxPoller.RunAsync();
            }

            // Send name, if any, to node ending
            if (!string.IsNullOrEmpty(name))
            {
                _actor.SendMoreFrame("SET NAME").SendFrame(name);
            }
        }
Esempio n. 5
0
        /// <summary>
        ///
        /// </summary>
        private void ServerLoop()
        {
            if (Thread.CurrentThread.Name == null)
            {
                Thread.CurrentThread.Name = "Nyx Hub Server Loop";
            }

            _disposables.Add(NyxMessageStream.Subscribe(RepSocketOnReceiveReady, x => _logger.Error("Error processing stream.", x)));
            _hubActor?.Dispose();
            _hubActor = NetMQActor.Create(new HubShimHandler(_inMessage, Port));

            _logger.Debug("Starting hub server loop...");
            _isStarted = true;
            _plugman.StartAllPlugins();
            _nodeStatusSubject.OnNext(NyxNodeStatus.Started);
            // Endless loop until request to stop, then shutdowns
            while (!_serverCancelToken.IsCancellationRequested)
            {
                _serverEvent.WaitOne(TimeSpan.FromSeconds(60));
            }
            _plugman.StopAllPlugins();
            Status = NyxNodeStatus.Stopped;
            _nodeStatusSubject.OnNext(Status);
            try
            {
                _hubActor?.SendFrame(NetMQActor.EndShimMessage);
                _hubActor?.Dispose();
            }
            catch (TerminatingException)
            {
                // Ignore and go
            }
            _isStarted = false;
        }
        /// <summary>
        /// Create reliable client
        /// </summary>
        /// <param name="context"></param>
        /// <param name="addresses">addresses of the reliable servers</param>
        public ReliableClient(NetMQContext context, params string[] addresses)
        {
            m_context = context;
            m_addresses = addresses;

            m_actor = NetMQActor.Create(context, Run);
        }
Esempio n. 7
0
        /// <summary>
        /// Create a Zyre API that communicates with a node on the ZRE bus.
        /// </summary>
        /// <param name="name">The name of the node</param>
        /// <param name="useEvents">Set this to true to disable Receive() and instead subscribe to events for getting messages from peers. Default is true.</param>
        /// <param name="loggerDelegate">An action to take for logging when _verbose is true. Default is null.</param>
        public Zyre(string name, bool useEvents = true, Action <string> loggerDelegate = null)
        {
            _useEvents = useEvents;
            // Create front-to-back pipe pair for data traffic
            // outbox is passed to ZyreNode for sending Zyre message traffic back to _inbox
            PairSocket outbox;

            PairSocket.CreateSocketPair(out outbox, out _inbox);

            // Start node engine and wait for it to be ready
            // All node control is done through _actor

            _actor = ZyreNode.Create(outbox, loggerDelegate);

            if (useEvents)
            {
                _inboxPoller         = new NetMQPoller();
                _inbox.ReceiveReady += InboxReceiveReady;
                _inboxPoller.RunAsync();
            }

            // Send name, if any, to node ending
            if (!string.IsNullOrEmpty(name))
            {
                _actor.SendMoreFrame("SET NAME").SendFrame(name);
            }
        }
Esempio n. 8
0
        public void Simple()
        {
            void ShimAction(PairSocket shim)
            {
                shim.SignalOK();

                while (true)
                {
                    var msg     = shim.ReceiveMultipartMessage();
                    var command = msg[0].ConvertToString();

                    if (command == NetMQActor.EndShimMessage)
                    {
                        break;
                    }

                    if (command == "Hello")
                    {
                        Assert.AreEqual(2, msg.FrameCount);
                        Assert.AreEqual("Hello", msg[1].ConvertToString());
                        shim.SendFrame("World");
                    }
                }
            }

            using (var actor = NetMQActor.Create(ShimAction))
            {
                actor.SendMoreFrame("Hello").SendFrame("Hello");

                Assert.AreEqual("World", actor.ReceiveFrameString());
            }
        }
Esempio n. 9
0
        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());
                }
            }
        }
        public ReliableServer(NetMQContext context, string address)
        {
            m_context = context;
            m_address = address;

            // actor is like thread with builtin pair sockets connect the user thread with the actor thread
            m_actor = NetMQActor.Create(context, Run);
        }
Esempio n. 11
0
 public void Stop()
 {
     if (_actor != null)
     {
         _actor.Dispose();
         _actor = null;
     }
 }
Esempio n. 12
0
        /// <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);
        }
Esempio n. 13
0
        public ReliableServer(TimeSpan heartbeatInterval, string address)
        {
            _address           = address;
            _heartbeatInterval = heartbeatInterval;

            // actor is like thread with builtin pair sockets connect the user thread with the actor thread
            _actor = NetMQActor.Create(Run);
        }
Esempio n. 14
0
 public void Start()
 {
     if (actor != null)
     {
         return;
     }
     actor = NetMQActor.Create(new ShimHandler(Address, (topic, value) => RaiseSubscriberMessageReceived(topic, value)));
 }
Esempio n. 15
0
 public void Stop()
 {
     if (actor != null)
     {
         actor.Dispose();
         actor = null;
     }
 }
Esempio n. 16
0
 public void Start()
 {
     if (_actor != null)
     {
         return;
     }
     _actor = NetMQActor.Create(new ShimHandler());
 }
Esempio n. 17
0
 public PeerBus(IHubContext <NotificationHub> hub, IOptions <WebServerOptions> options, ILogger <PeerBus> logger)
 {
     _id         = $"[{options.Value.ServerId}]";
     _info       = new Dictionary <PeerInfo, DateTimeOffset>();
     _beaconPort = options.Value.BeaconPort;
     _hub        = hub;
     _logger     = logger;
     _actor      = NetMQActor.Create(RunActor);
 }
Esempio n. 18
0
 /// <summary>
 /// Create reliable client
 /// </summary>
 /// <param name="reconnectInterval"></param>
 /// <param name="subscriberMessageHandler"></param>
 /// <param name="subscriberErrorHandler"></param>
 /// <param name="addresses">addresses of the reliable servers</param>
 /// <param name="heartbeatTimeOut"></param>
 public ReliableClient(IEnumerable <string> addresses, TimeSpan heartbeatTimeOut, TimeSpan reconnectInterval, Action <NetMQMessage> subscriberMessageHandler = null, Action <Exception, NetMQMessage> subscriberErrorHandler = null, Action welcomeMessageHandler = null)
 {
     _heartbeatTimeOut         = heartbeatTimeOut;
     _reconnectInterval        = reconnectInterval;
     _addresses                = addresses;
     _subscriberMessageHandler = subscriberMessageHandler;
     _subscriberErrorHandler   = subscriberErrorHandler;
     _welcomeMessageHandler    = welcomeMessageHandler;
     _actor = NetMQActor.Create(Run);
 }
Esempio n. 19
0
        public ReliableServer(TimeSpan heartbeatInterval, string address, int receiveTimeout = 0, Action onReceiveTimeout = null)
        {
            _address           = address;
            _receiveTimeout    = receiveTimeout;
            _onReceiveTimeout  = onReceiveTimeout;
            _heartbeatInterval = heartbeatInterval;

            // actor is like thread with builtin pair sockets connect the user thread with the actor thread
            _actor = NetMQActor.Create(Run);
        }
Esempio n. 20
0
 /// <summary>
 ///     Init or reinit all communications.
 /// </summary>
 public void Init()
 {
     if (Interlocked.CompareExchange(ref _requiresInitialisation, 0, 1) == 0)
     {
         return;
     }
     _actor?.SendFrame(NetMQActor.EndShimMessage);
     _actor?.Dispose();
     _actor = NetMQActor.Create(new ShimHandler(this, _connectionSubject, _address, _port));
 }
Esempio n. 21
0
        /// <summary>
        /// 构造
        /// </summary>
        /// <param name="address"></param>
        /// <param name="shimCreator"></param>
        protected WsSocket(string address, Func <int, string, BaseShimHandler> shimCreator)
        {
            Id = Interlocked.Increment(ref _id);

            _messagesPipe = new PairSocket();
            _messagesPipe.Bind($"inproc://wsrouter-{Id}");
            _messagesPipe.ReceiveReady += OnMessagePipeReceiveReady;
            _actor = NetMQActor.Create(ShimHandler = shimCreator(Id, address));

            _messagesPipe.ReceiveSignal();
        }
Esempio n. 22
0
        public SnapshotServer(string address, ISnapshotGenerator snapshotGenerator)
        {
            if (snapshotGenerator == null)
            {
                throw new ArgumentNullException(nameof(snapshotGenerator));
            }

            _address           = address;
            _snapshotGenerator = snapshotGenerator;
            _actor             = NetMQActor.Create(Run);
        }
Esempio n. 23
0
        /// <summary>
        /// Create a new ZreBeacon, contained within the given context.
        /// </summary>
        /// <param name="context">the NetMQContext to contain this new socket</param>
        public ZreBeacon(NetMQContext context)
        {
            _actor = NetMQActor.Create(context, new Shim());

            EventHandler<NetMQActorEventArgs> onReceive = (sender, e) =>
                                                          _receiveEvent.Fire(this, new ZreBeaconEventArgs(this));

            _receiveEvent = new EventDelegator<ZreBeaconEventArgs>(
                () => _actor.ReceiveReady += onReceive,
                () => _actor.ReceiveReady -= onReceive);
        }
Esempio n. 24
0
        /// <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());

            EventHandler<NetMQActorEventArgs> onReceive = (sender, e) =>
                m_receiveEvent.Fire(this, new NetMQBeaconEventArgs(this));

            m_receiveEvent = new EventDelegator<NetMQBeaconEventArgs>(
                () => m_actor.ReceiveReady += onReceive,
                () => m_actor.ReceiveReady -= onReceive);
        }
Esempio n. 25
0
        public void EchoActorSendReceiveTests(string actorMessage)
        {
            using (var actor = NetMQActor.Create(new EchoShimHandler()))
            {
                actor.SendMoreFrame("ECHO");
                actor.SendFrame(actorMessage);

                Assert.AreEqual(
                    $"ECHO BACK : {actorMessage}",
                    actor.ReceiveFrameString());
            }
        }
        public void ShimExceptionTest()
        {
            using (var actor = NetMQActor.Create(new ExceptionShimHandler()))
            {
                actor.SendMoreFrame("SOME_COMMAND");
                actor.SendFrame("Whatever");

                Assert.AreEqual(
                    "Error: Exception occurred Actors Shim threw an Exception",
                    actor.ReceiveFrameString());
            }
        }
Esempio n. 27
0
        public void BadCommandTests(string command)
        {
            const string actorMessage = "whatever";

            using (var actor = NetMQActor.Create(new EchoShimHandler()))
            {
                actor.SendMoreFrame(command);
                actor.SendFrame(actorMessage);

                Assert.AreEqual("Error: invalid message to actor", actor.ReceiveFrameString());
            }
        }
Esempio n. 28
0
        public void EchoActorSendReceiveTests(string actorMessage)
        {
            using (var context = NetMQContext.Create())
                using (var actor = NetMQActor.Create(context, new EchoShimHandler()))
                {
                    actor.SendMore("ECHO");
                    actor.Send(actorMessage);

                    Assert.AreEqual(
                        string.Format("ECHO BACK : {0}", actorMessage),
                        actor.ReceiveFrameString());
                }
        }
Esempio n. 29
0
        protected WSSocket(Func <int, IShimHandler> shimCreator)
        {
            int id = Interlocked.Increment(ref s_id);

            m_messagesPipe = new PairSocket();
            m_messagesPipe.Bind(string.Format("inproc://wsrouter-{0}", id));

            m_messagesPipe.ReceiveReady += OnMessagePipeReceiveReady;

            m_actor = NetMQActor.Create(shimCreator(id));

            m_messagesPipe.ReceiveSignal();
        }
        /// <summary>
        /// Starts this instance.
        /// </summary>
        public void Start()
        {
            lock (_lockSocket)
            {
                _actor = _bus.Start();
            }
            _currentTaskCount = 0;
            _running          = true;
            try
            {
                lock (_lockSocket)
                {
                    _actor.SendFrame(TaskSchedulerBusCommands.GetHostAddress.ToString());
                }
                _hostAddress = _actor.ReceiveFrameString();
                _hostPort    = new Uri("http://" + _hostAddress).Port;

                //second beacon time, so we wait to ensure beacon has fired
                Thread.Sleep(1100);

                //let other nodes know we are here
                lock (_lockSocket)
                {
                    _actor.SendMoreFrame(TaskSchedulerBusCommands.Publish.ToString())
                    .SendMoreFrame(TaskSchedulerBusCommands.BroadCast.ToString())
                    .SendFrame(_hostAddress);
                }

                // receive messages from other nodes on the bus
                while (!_stopRequested)
                {
                    try
                    {
                        ProcessMessages();
                    }
                    catch (Exception error)
                    {
                        _log.ErrorException("Failed to handle NetMCQ commands", error);
                    }
                }
            }
            catch (Exception error)
            {
                _log.ErrorException("A fatal error occurred while processing NetMCQ commands", error);
            }
            finally
            {
                _running = false;
            }
        }
Esempio n. 31
0
        private NetMQActor CreateActor()
        {
            return(NetMQActor.Create(shim =>
            {
                Shim = shim;
                Shim.ReceiveReady += ShimOnReceiveReady;
                Shim.SignalOK();

                Poller.Add(Shim);
                Poller.Add(ListeningSocket);
                Poller.Run();

                Log("Node closed");
            }));
        }
Esempio n. 32
0
        private NetMQActor CreateActor()
        {
            return(NetMQActor.Create(shim =>
            {
                Shim = shim;
                Shim.ReceiveReady += ShimOnReceiveReady;

                Poller.Add(ListeningSocket);
                Poller.Add(InitTimer);
                Poller.Add(Shim);

                Shim.SignalOK();
                Poller.Run();
            }));
        }
Esempio n. 33
0
        public void AccountActorJsonSendReceiveTests()
        {
            var account       = new Account(1, "Test Account", "11223", 0);
            var accountAction = new AccountAction(TransactionType.Credit, 10);

            using (var actor = NetMQActor.Create(new AccountShimHandler()))
            {
                actor.SendMoreFrame("AMEND ACCOUNT");
                actor.SendMoreFrame(JsonConvert.SerializeObject(accountAction));
                actor.SendFrame(JsonConvert.SerializeObject(account));

                var updatedAccount = JsonConvert.DeserializeObject <Account>(actor.ReceiveFrameString());

                Assert.Equal(10.0m, updatedAccount?.Balance ?? 0);
            }
        }
Esempio n. 34
0
        private Zre(NetMQContext context, string name)
        {
            _name = name;
            _actor = NetMQActor.Create(context, new ZreNode(context));
            if (!string.IsNullOrEmpty(name))
            {
                Name = name;
            }

            EventHandler<NetMQActorEventArgs> onReceive = (sender, e) =>
                                              _receiveEvent.Fire(this, new ZreEventArgs(this));

            _receiveEvent = new EventDelegator<ZreEventArgs>(
                () => _actor.ReceiveReady += onReceive,
                () => _actor.ReceiveReady -= onReceive);
        }
Esempio n. 35
0
        private ZyreNode(PairSocket outbox, Action <string> loggerDelegate = null)
        {
            _outbox         = outbox;
            _loggerDelegate = loggerDelegate;

            _beaconPort = ZreDiscoveryPort;
            _interval   = TimeSpan.Zero; // Use default
            _uuid       = Guid.NewGuid();
            _peers      = new Dictionary <Guid, ZyrePeer>();
            _peerGroups = new Dictionary <string, ZyreGroup>();
            _ownGroups  = new Dictionary <string, ZyreGroup>();
            _headers    = new Dictionary <string, string>();

            //  Default name for node is first 6 characters of UUID:
            //  the shorter string is more readable in logs
            _name = _uuid.ToShortString6();

            //  Use ZMQ_ROUTER_HANDOVER so that when a peer disconnects and
            //  then reconnects, the new client connection is treated as the
            //  canonical one, and any old trailing commands are discarded.
            //  This RouterHandover option is currently not supported in NetMQ Feb 16 2016

            _actor = NetMQActor.Create(RunActor);
        }
Esempio n. 36
0
 /// <summary>
 /// Create new server
 /// </summary>
 /// <param name="serializer">Serializer to use to serialize messages</param>
 /// <param name="asyncHandler">Handler to handle messages from client</param>
 public AsyncServer(ISerializer serializer, IAsyncHandler asyncHandler)
 {            
     m_actor = NetMQActor.Create(new AsyncServerEngine(serializer, asyncHandler));
 }
Esempio n. 37
0
        /// <summary>
        /// Release any contained resources.
        /// </summary>
        /// <param name="disposing">true if managed resources are to be released</param>
        protected virtual void Dispose(bool disposing)
        {
            if (!disposing)
                return;

            if (_actor != null)
            {
                _actor.Dispose();
                _actor = null;
            }
            if (_inbox != null)
            {
                _inbox.Dispose();
                _inbox = null;
            }
        }
Esempio n. 38
0
        private ZreNode(PairSocket outbox)
        {
            _inbox = new RouterSocket();

            //  Use ZMQ_ROUTER_HANDOVER so that when a peer disconnects and
            //  then reconnects, the new client connection is treated as the
            //  canonical one, and any old trailing commands are discarded.
            // NOTE: This RouterHandover option apparently doesn't exist in NetMQ 
            //      so I IGNORE it for now. DaleBrubaker Feb 1 2016

            _outbox = outbox;
            //_beaconPort = ZreDiscoveryPort;
            _interval = TimeSpan.Zero; // Use default
            _uuid = Guid.NewGuid();
            _peers = new Dictionary<Guid, ZrePeer>();
            _peerGroups = new Dictionary<string, ZreGroup>();
            _ownGroups = new Dictionary<string, ZreGroup>();
            _headers = new Dictionary<string, string>();

            //  Default name for node is first 6 characters of UUID:
            //  the shorter string is more readable in logs
            _name = _uuid.ToString().ToUpper().Substring(0, 6);

            _actor = NetMQActor.Create(RunActor);
        }
Esempio n. 39
0
File: Bus.cs Progetto: vadian/netmq
 private Bus(int broadcastPort)
 {
     m_nodes = new Dictionary<NodeKey, DateTime>();
     m_broadcastPort = broadcastPort;
     m_actor = NetMQActor.Create(RunActor);
 }
Esempio n. 40
0
 /// <summary>
 /// Create new wokrer
 /// </summary>
 /// <param name="serializer">Serializer to use to serialize messages</param>
 /// <param name="handler">Handler to handle messages from client</param>
 /// <param name="loadBalancerAddress">Address of load balancer to connect to</param>
 public Worker(ISerializer serializer, IHandler handler, string loadBalancerAddress)
 {
     m_actor = NetMQActor.Create(new WorkerEngine(serializer, handler, loadBalancerAddress));
 }
Esempio n. 41
0
 public OutgoingSocket(NetMQActor socket, IUtcClock clock)
 {
     _clock      = clock;
     Socket      = socket;
     _isDisposed = true; // Actor is not owned by the cache
 }
Esempio n. 42
0
        private ZyreNode(PairSocket outbox, Action<string> loggerDelegate = null)
        {
            _outbox = outbox;
            _loggerDelegate = loggerDelegate;

            _beaconPort = ZreDiscoveryPort;
            _interval = TimeSpan.Zero; // Use default
            _uuid = Guid.NewGuid();
            _peers = new Dictionary<Guid, ZyrePeer>();
            _peerGroups = new Dictionary<string, ZyreGroup>();
            _ownGroups = new Dictionary<string, ZyreGroup>();
            _headers = new Dictionary<string, string>();

            //  Default name for node is first 6 characters of UUID:
            //  the shorter string is more readable in logs
            _name = _uuid.ToShortString6();

            //  Use ZMQ_ROUTER_HANDOVER so that when a peer disconnects and
            //  then reconnects, the new client connection is treated as the
            //  canonical one, and any old trailing commands are discarded.
            //  This RouterHandover option is currently not supported in NetMQ Feb 16 2016
            
            _actor = NetMQActor.Create(RunActor);
        }
Esempio n. 43
0
        public Zyre (string name)
        {
            // Create front-to-back pipe pair for data traffic
            // outbox is passed to ZreNode for sending Zyre message traffic back to _inbox
            PairSocket outbox;
            PairSocket.CreateSocketPair(out outbox, out _inbox);

            // Start node engine and wait for it to be ready
            // All node control is done through _actor
            _actor = ZreNode.Create(outbox);

            // Send name, if any, to node ending
            if (!string.IsNullOrEmpty(name))
            {
                _actor.SendMoreFrame("SET NAME").SendFrame(name);
            }
        }
Esempio n. 44
0
 private Bus(int broadcastPort)
 {
     m_nodes         = new Dictionary <NodeKey, DateTime>();
     m_broadcastPort = broadcastPort;
     m_actor         = NetMQActor.Create(RunActor);
 }
Esempio n. 45
0
        private void StartGossip()
        {
            //  If we haven't already set-up the gossip network, do so
            if (_gossip == null)
            {
                _beaconPort = 0; //  Disable UDP beaconing
                _gossip = NetMQActor.Create(
                    _context,
                    shim =>
                    {
                    });

                if (_verbose)
                {
                    _gossip.SendFrame(Zre.SetVerboseCommand);
                }
            }
        }
Esempio n. 46
0
 /// <summary>
 /// Create NetMQProactor and start dedicate thread to handle incoming messages.
 /// </summary>
 /// <param name="receiveSocket">Socket to handle messages from</param>
 /// <param name="handler">Handler to handle incoming messages</param>
 public NetMQProactor(NetMQSocket receiveSocket, Action<NetMQSocket, NetMQMessage> handler)
 {
     m_receiveSocket = receiveSocket;
     m_handler = handler;
     m_actor = NetMQActor.Create(Run);
 }
Esempio n. 47
0
 public LoadBalancer(string frontendAddress, string backendAddress)
 {
     m_actor = NetMQActor.Create(new LoadBalancerEngine(frontendAddress, backendAddress));
 }
Esempio n. 48
0
 /// <summary>
 /// Create new client
 /// </summary>
 /// <param name="serializer">Serialize to to use to serialize the message to byte array</param>
 /// <param name="address">Address of the server</param>        
 public Client(ISerializer serializer, string address)
 {
     m_outgoingQueue = new NetMQQueue<ClientEngine.OutgoingMessage>();
     m_actor = NetMQActor.Create(new ClientEngine(serializer, m_outgoingQueue, address));
 }