Inheritance: System.EventArgs
コード例 #1
0
		private void OnReceiveMessage(object sender, NetMQSocketEventArgs e)
		{
			var message = e.Socket.ReceiveMultipartMessage();
			var connectionId = e.Socket is RouterSocket && message.FrameCount > 1 ? message.First.ToByteArray() : null;
			var segment = new ArraySegment<byte>(message.Last.Buffer, 0, message.Last.MessageSize);
			Received.Invoke(this, new DataReceivedArgs { Data = segment, SessionID = connectionId });
		}
コード例 #2
0
ファイル: Program.cs プロジェクト: JayShelton/netmq
        private const int REQUEST_TIMEOUT = 1000; // ms

        #endregion Fields

        #region Methods

        private static void ClientOnReceiveReady(object sender, NetMQSocketEventArgs e)
        {
            bool hasMore = true;

            var reply = e.Socket.ReceiveString(out hasMore);
            Console.WriteLine("Server replied ({0})", reply);
        }
コード例 #3
0
        private void OnBackendReady(object sender, NetMQSocketEventArgs e)
        {
            Msg msg = new Msg();

            msg.InitEmpty();

            Msg copy = new Msg();

            copy.InitEmpty();

            while (true)
            {
                m_backend.Receive(ref msg, SendReceiveOptions.None);
                bool more = m_backend.Options.ReceiveMore;

                if (m_control != null)
                {
                    copy.Copy(ref msg);

                    m_control.Send(ref copy, more ? SendReceiveOptions.SendMore : SendReceiveOptions.None);
                }

                m_frontend.Send(ref msg, more ? SendReceiveOptions.SendMore : SendReceiveOptions.None);



                if (!more)
                {
                    break;
                }
            }

            copy.Close();
            msg.Close();
        }
コード例 #4
0
ファイル: NetMQSocket.cs プロジェクト: GerHobbelt/netmq
 /// <summary>
 /// Create a new NetMQSocket with the given <see cref="SocketBase"/>.
 /// </summary>
 /// <param name="socketHandle">a SocketBase object to assign to the new socket</param>
 internal NetMQSocket(SocketBase socketHandle)
 {
     m_netMqSelector   = new NetMQSelector();
     m_socketHandle    = socketHandle;
     Options           = new SocketOptions(this);
     m_socketEventArgs = new NetMQSocketEventArgs(this);
 }
コード例 #5
0
ファイル: Program.cs プロジェクト: EugenDueck/netmq
        private static void FrontendOnReceiveReady(object sender, NetMQSocketEventArgs socket)
        {
            //  Now get next client request, route to next worker
            //  Dequeue and drop the next worker address

            //  Now get next client request, route to LRU worker
            //  Client request is [address][empty][request]
            byte[] clientAddr = socket.Socket.Receive();
            byte[] empty = socket.Socket.Receive();
            byte[] request = socket.Socket.Receive();

            byte[] deq;
            try
            {
                deq = workerQueue.Dequeue();
                backend.SendMore(deq);
                backend.SendMore(Encoding.Unicode.GetBytes(""));
                backend.SendMore(clientAddr);
                backend.SendMore(Encoding.Unicode.GetBytes(""));
                backend.Send(request);
            }
            catch (Exception exc)
            {
                Console.WriteLine("Q: [FrontendOnReceiveReady] Dequeue exc: {0}", exc.ToString());
            }
        }
コード例 #6
0
ファイル: Chat.cs プロジェクト: torshy/DotNetZyre
        private void OnPipeReady(object sender, NetMQSocketEventArgs e)
        {
            var message = e.Socket.ReceiveMultipartMessage();
            var command = message.Pop().ConvertToString();
            switch (command)
            {
                case ShoutCommand:
                {
                    _zre.Shout("GLOBAL", message.Pop().ConvertToString());
                }
                break;
                case InterfaceCommand:
                {
                    _zre.SetInterface(message.Pop().ConvertToString());

                }
                break;
                case StartCommand:
                {
                    _zre.SetVerbose();
                    _zre.SetHeader("X-TYPE", "CHAT");
                    _zre.SetHeader("X-PID", Process.GetCurrentProcess().Id.ToString());
                    _zre.Start();
                    _zre.Join("GLOBAL");
                }
                break;
            }
        }
コード例 #7
0
 private void RepSocketOnReceiveReady(object sender, NetMQSocketEventArgs netMqSocketEventArgs)
 {
     netMqSocketEventArgs.Socket.Receive();
     var quotes = market.Select(pair => string.Format("{0}={1}", pair.Key, pair.Value));
     var data = string.Join(";", quotes);
     netMqSocketEventArgs.Socket.Send(data);
 }
コード例 #8
0
 /// <summary>
 /// Create a new NetMQSocket with the given <see cref="SocketBase"/>.
 /// </summary>
 /// <param name="socketHandle">a SocketBase object to assign to the new socket</param>
 internal NetMQSocket([NotNull] SocketBase socketHandle)
 {
     m_selector        = new Selector();
     m_socketHandle    = socketHandle;
     Options           = new SocketOptions(this);
     m_socketEventArgs = new NetMQSocketEventArgs(this);
 }
コード例 #9
0
ファイル: Program.cs プロジェクト: EugenDueck/netmq
        private static void BackendOnReceiveReady(object sender, NetMQSocketEventArgs socket)
        {
            //  Queue worker address for LRU routing
            byte[] workerAddress = socket.Socket.Receive();

            //  Use worker address for LRU routing
            workerQueue.Enqueue(workerAddress);

            //  Second frame is empty
            byte[] empty = socket.Socket.Receive();

            //  Third frame is READY or else a client reply address
            byte[] clientAddress = socket.Socket.Receive();

            //  If client reply, send rest back to frontend
            //  Forward message to client if it's not a READY
            if (Encoding.Unicode.GetString(clientAddress) != LRU_READY)
            {
                empty = socket.Socket.Receive();
                byte[] reply = socket.Socket.Receive();

                frontend.SendMore(clientAddress);
                frontend.SendMore("");
                frontend.Send(reply);
            }
        }
コード例 #10
0
ファイル: NetMQProactor.cs プロジェクト: cjkao/netmq
 private void OnShimReady(object sender, NetMQSocketEventArgs e)
 {
     string command = e.Socket.ReceiveFrameString();
     if (command == NetMQActor.EndShimMessage)
     {
         m_poller.Stop();
     }
 }
コード例 #11
0
		private void SubscribeSocketOnReceiveReady(object sender, NetMQSocketEventArgs args)
		{
			NetMQMessage message = args.Socket.ReceiveMessage();

			if (message.FrameCount >= 2)
			{
				MessageReceived.Invoke(this, new MessageEventArgs(message[0].ConvertToString(), message[1].ConvertToString()));
			}
		}
コード例 #12
0
        private static void Socket_ReceiveReady(object sender, NetMQ.NetMQSocketEventArgs e)
        {
            var topic = e.Socket.ReceiveFrameString();
            var dt    = e.Socket.ReceiveFrameString();
            //Console.WriteLine(dt);
            var t = DateTime.Now.Subtract(new DateTime(Convert.ToInt64(dt)));

            d.Add(t);
        }
コード例 #13
0
ファイル: NetMQSocket.cs プロジェクト: ryanjshaw/netmq
        protected NetMQSocket(SocketBase socketHandle)
        {
            m_socketHandle    = socketHandle;
            Options           = new SocketOptions(this);
            m_socketEventArgs = new NetMQSocketEventArgs(this);

            IgnoreErrors = false;
            Errors       = 0;
        }
コード例 #14
0
        private void OnShimReady(object sender, NetMQSocketEventArgs e)
        {
            string command = e.Socket.ReceiveFrameString();

            if (command == NetMQActor.EndShimMessage)
            {
                m_poller.Stop();
            }
        }
コード例 #15
0
        private static void SubSocketOnReceiveReady(object sender, NetMQSocketEventArgs args)
        {
            NetMQMessage message = args.Socket.ReceiveMessage();

            Console.WriteLine("Message Received:");
            foreach (NetMQFrame frame in message)
            {
                Console.WriteLine("\t{0}", frame.ConvertToString());
            }
        }
コード例 #16
0
ファイル: NetMQScheduler.cs プロジェクト: xuzhe35/netmq
        private void OnMessage(object sender, NetMQSocketEventArgs e)
        {
            // remove the awake command from the queue
            m_serverSocket.Receive();

            Task task;

            while (m_tasksQueue.TryDequeue(out task))
            {
                TryExecuteTask(task);
            }
        }
コード例 #17
0
ファイル: NetMQScheduler.cs プロジェクト: xuzhe35/netmq
        private void OnMessageFirstTime(object sender, NetMQSocketEventArgs e)
        {
            // set the current thread as the scheduler thread, this only happen the first time message arrived and important for the TryExecuteTaskInline
            m_schedulerThread.Value = true;

            // stop calling the OnMessageFirstTime and start calling OnMessage
            m_serverSocket.ReceiveReady -= m_currentMessageHandler;
            m_currentMessageHandler      = OnMessage;
            m_serverSocket.ReceiveReady += m_currentMessageHandler;

            OnMessage(sender, e);
        }
コード例 #18
0
ファイル: Program.cs プロジェクト: EugenDueck/netmq
        private static void WorkerOnReceiveReady(object sender, NetMQSocketEventArgs socket)
        {
            //  Read and save all frames until we get an empty frame
            //  In this example there is only 1 but it could be more
            byte[] address = worker.Receive();
            byte[] empty = worker.Receive();
            byte[] request = worker.Receive();

            worker.SendMore(address);
            worker.SendMore(Encoding.Unicode.GetBytes(""));
            worker.Send(Encoding.Unicode.GetBytes(Encoding.Unicode.GetString(request) + " WORLD!"));
        }
コード例 #19
0
        private void Client_ReceivedReady(object sender, NetMQSocketEventArgs e)
        {
            bool hasMore = false;

            e.Socket.ReceiveFrameString(out hasMore);

            if (hasMore)
            {
                string message = e.Socket.ReceiveFrameString(out hasMore);
                Console.WriteLine("Reply:{0}", message);
            }
        }
コード例 #20
0
ファイル: Program.cs プロジェクト: JayShelton/netmq
        private static void ClientOnReceiveReady(object sender, NetMQSocketEventArgs socket)
        {
            var reply = socket.Socket.Receive();

            if (Encoding.Unicode.GetString(reply) == (_strSequenceSent + " WORLD!"))
            {
                Console.WriteLine("C: Server replied OK ({0})", Encoding.Unicode.GetString(reply));
                _retriesLeft = REQUEST_RETRIES;
                _expectReply = false;
            }
            else
            {
                Console.WriteLine("C: Malformed reply from server: {0}", Encoding.Unicode.GetString(reply));
            }
        }
コード例 #21
0
        private void OnShimMessage(object sender, NetMQSocketEventArgs e)
        {
            string command = e.Socket.ReceiveFrameString();

            if (command == PublishMessageCommand)
            {
                // just forward the message to the publisher
                NetMQMessage message = e.Socket.ReceiveMultipartMessage();
                m_publisherSocket.SendMultipartMessage(message);
            }
            else if (command == NetMQActor.EndShimMessage)
            {
                // we got dispose command, we just stop the poller
                m_poller.Cancel();
            }
        }
コード例 #22
0
ファイル: Program.cs プロジェクト: JayShelton/netmq
        private static void ClientOnReceiveReady(object sender, NetMQSocketEventArgs netMqSocketEventArgs)
        {
            var reply = netMqSocketEventArgs.Socket.Receive();
            string strReply = Encoding.Unicode.GetString(reply);

            if (Int32.Parse(strReply) == _sequence)
            {
                Console.WriteLine("C: Server replied OK ({0})", strReply);
                _retriesLeft = REQUEST_RETRIES;
                _expectReply = false;
            }
            else
            {
                Console.WriteLine("C: Malformed reply from server: {0}", strReply);
            }
        }
コード例 #23
0
ファイル: NetMQBeacon.cs プロジェクト: wbskyboy/netmq
            private void OnPipeReady(object sender, NetMQSocketEventArgs e)
            {
                Assumes.NotNull(m_pipe);
                Assumes.NotNull(m_pingTimer);
                Assumes.NotNull(m_poller);

                NetMQMessage message = m_pipe.ReceiveMultipartMessage();

                string command = message.Pop().ConvertToString();

                switch (command)
                {
                case ConfigureCommand:
                    string interfaceName = message.Pop().ConvertToString();
                    int    port          = message.Pop().ConvertToInt32();
                    Configure(interfaceName, port);
                    break;

                case PublishCommand:
                    m_transmit           = message.Pop();
                    m_pingTimer.Interval = message.Pop().ConvertToInt32();
                    m_pingTimer.Enable   = true;
                    SendUdpFrame(m_transmit);
                    break;

                case SilenceCommand:
                    m_transmit         = null;
                    m_pingTimer.Enable = false;
                    break;

                case SubscribeCommand:
                    m_filter = message.Pop();
                    break;

                case UnsubscribeCommand:
                    m_filter = null;
                    break;

                case NetMQActor.EndShimMessage:
                    m_poller.Stop();
                    break;

                default:
                    throw new ArgumentOutOfRangeException();
                }
            }
コード例 #24
0
ファイル: XForwarder.cs プロジェクト: yonglehou/Daytona
        protected override void FrontendHandler(object sender, NetMQSocketEventArgs args)
        {
            bool more;

            do
            {
                var data = args.Socket.Receive(out more);

                if (more)
                    this.BackendSocket.SendMore(data);
                else
                {
                    this.BackendSocket.Send(data);
                }

            } while (more);
        }
コード例 #25
0
ファイル: AsyncBrocker.cs プロジェクト: buldo/MQExperiments
 private void SocketReceiveReady(object sender, NetMQSocketEventArgs e)
 {
     var ba = e.Socket.ReceiveMultipartMessage();
     if (ba != null)
     {
         using (var ms = new MemoryStream())
         {
             ms.Write(ba[2].ToByteArray(), 0, ba[2].MessageSize);
             ms.Position = 0;
             var data = (ProcessedEventArgs)_formatter.Deserialize(ms);
             _logger.Trace("Brocker received result queue {0}", data.QueueId);
             OnFramesProcessed(data);
         }
     }
     else
     {
         _logger.Trace("Brocker not received");
     }
 }
コード例 #26
0
        internal NetMQSocket(ZmqSocketType socketType, string?connectionString, DefaultAction defaultAction)
        {
            m_socketHandle    = NetMQConfig.Context.CreateSocket(socketType);
            m_netMqSelector   = new NetMQSelector();
            Options           = new SocketOptions(this);
            m_socketEventArgs = new NetMQSocketEventArgs(this);

            Options.Linger = NetMQConfig.Linger;

            if (!Strings.IsNullOrEmpty(connectionString))
            {
                var endpoints = connectionString
                                .Split(new[] { ',' }, StringSplitOptions.RemoveEmptyEntries)
                                .Select(a => a.Trim())
                                .Where(a => !string.IsNullOrEmpty(a));

                foreach (var endpoint in endpoints)
                {
                    switch (endpoint[0])
                    {
                    case '@':
                        Bind(endpoint.Substring(1));
                        break;

                    case '>':
                        Connect(endpoint.Substring(1));
                        break;

                    default:
                        if (defaultAction == DefaultAction.Connect)
                        {
                            Connect(endpoint);
                        }
                        else
                        {
                            Bind(endpoint);
                        }
                        break;
                    }
                }
            }
        }
コード例 #27
0
ファイル: Program.cs プロジェクト: hdxhan/netmq
        private static void RepOnReceiveReady(object sender, NetMQSocketEventArgs args)
        {
            try
            {
                NetMQSocket rep = args.Socket;

                byte[] message = rep.ReceiveFrameBytes();

                //Thread.Sleep(1000); //  Simulate 'work'

                byte[] response =
                    Encoding.Unicode.GetBytes(Encoding.Unicode.GetString(message) + " World from worker " + Encoding.Unicode.GetString(rep.Options.Identity));

                rep.TrySendFrame(response, response.Length);
            }
            catch (Exception ex)
            {
                Console.WriteLine("Exception on RepOnReceiveReady: {0}", ex.Message);
                throw;
            }
        }
コード例 #28
0
        private void OnReceiveImageMessage(object sender, NetMQ.NetMQSocketEventArgs e)
        {
            bool more   = false;
            var  buffer = e.Socket.ReceiveFrameBytes(out more);

            if (!more)
            {
                var message = NetMq.Messages.BaseMessage.FromRawBuffer(buffer) as NetMq.Messages.ImageMessage;

                if (message != null)
                {
                    QueueImages.Enqueue(message);
                }

                while (QueueImages.Count > 10)
                {
                    NetMq.Messages.ImageMessage tmp;
                    QueueImages.TryDequeue(out tmp);
                }
            }
        }
コード例 #29
0
        private void OnReceiveControlMessage(object sender, NetMQ.NetMQSocketEventArgs e)
        {
            bool more   = false;
            var  buffer = e.Socket.ReceiveFrameBytes(out more);

            if (!more)
            {
                var message = NetMq.Messages.BaseMessage.FromRawBuffer(buffer);
                if (message == null)
                {
                    this.Log($"Error in {nameof(OnReceiveControlMessage)} - Received message is a null-reference");
                }
                else if (message.GetType() == typeof(NetMq.Messages.StateMessage))
                {
                    CounterStateMessage++;
                    var stateMessage = message as NetMq.Messages.StateMessage;
                    this.Log($"Received StateMessage -> CounterStateMessage: {CounterStateMessage} - State: {stateMessage?.State}", 0);
                }
                else if (message.GetType() == typeof(NetMq.Messages.AcquisitionStartMessage))
                {
                    var acquisitionStartMessage = message as NetMq.Messages.AcquisitionStartMessage;
                    this.Log($"Received AcquisitionStartMessage -> (Box)ID: {acquisitionStartMessage?.ID} - BoxType: {acquisitionStartMessage?.Type}");
                }
                else if (message.GetType() == typeof(NetMq.Messages.ProcessStartMessage))
                {
                    var processStartMessage = message as NetMq.Messages.ProcessStartMessage;
                    this.Log($"Received ProcessStartMessage -> (Box)ID: {processStartMessage?.ID} - BoxType: {processStartMessage?.BoxType}");
                    Task.Run(() => ProcessImages(processStartMessage.ID));
                }
                else if (message.GetType() == typeof(NetMq.Messages.ProcessCancelMessage))
                {
                    var processCancelMessage = message as NetMq.Messages.ProcessCancelMessage;
                    this.Log($"Received ProcessCancelMessage -> (Box)ID: {processCancelMessage?.ID}");
                }
                else
                {
                    this.Log($"Received {message.MessageType}");
                }
            }
        }
コード例 #30
0
        private void _routerSocket_ReceiveReady(object sender, NetMQ.NetMQSocketEventArgs e)
        {
            NetMQ.NetMQMessage msg = new NetMQ.NetMQMessage();
            if (e.Socket.TryReceiveMultipartMessage(ref msg, 3))
            {
                var address = msg.Pop();
                var empty   = msg.Pop();
                var data    = msg.Pop();


                var messageData = new MemoryRemoteSocketData()
                {
                    Address = new StageAddress()
                    {
                        Address = address.ConvertToString()
                    },
                    Data = data.Buffer
                };

                _inputBuffer.Post(messageData);
            }
        }
コード例 #31
0
        private void IncomingMessage(object sender, NetMQ.NetMQSocketEventArgs e)
        {
            NetMQMessage msg     = e.Socket.ReceiveMultipartMessage();
            Address      address = Address.FromFullPath(msg[0].ConvertToString());

            if (_connectedInputs.ContainsKey(address.ToString()))
            {
                foreach (InputPlug plug in _connectedInputs[address.ToString()])
                {
                    Message localmessage = Message.FromNetMQMessage(msg);

                    if (localmessage.address.endpoint != Endpoint.Name && Endpoint.GetType() != typeof(ZyreEndpoint))
                    {
                        Endpoint.Log("Received message intended for remote destination");
                        Endpoint.SendMessageToOwner(msg);
                    }
                    else
                    {
                        plug.IncomingMessage(localmessage);
                    }
                }
            }
        }
コード例 #32
0
ファイル: NetMQSocket.cs プロジェクト: yeowgit/netmq
        /// <summary>
        /// Create a new NetMQSocket with the given <see cref="ZmqSocketType"/>.
        /// </summary>
        /// <param name="socketType">Type of socket to create</param>
        internal NetMQSocket(ZmqSocketType socketType, string connectionString, DefaultAction defaultAction)
        {
            m_socketHandle    = NetMQConfig.Context.CreateSocket(socketType);
            m_selector        = new Selector();
            Options           = new SocketOptions(this);
            m_socketEventArgs = new NetMQSocketEventArgs(this);

            Options.Linger = NetMQConfig.Linger;

            if (!string.IsNullOrEmpty(connectionString))
            {
                var endpoints =
                    connectionString.Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries)
                    .Select(a => a.Trim()).Where(a => !string.IsNullOrEmpty(a));

                foreach (string endpoint in endpoints)
                {
                    if (endpoint[0] == '@')
                    {
                        Bind(endpoint.Substring(1));
                    }
                    else if (endpoint[0] == '>')
                    {
                        Connect(endpoint.Substring(1));
                    }
                    else if (defaultAction == DefaultAction.Connect)
                    {
                        Connect(endpoint);
                    }
                    else
                    {
                        Bind(endpoint);
                    }
                }
            }
        }
コード例 #33
0
        private void OnMessage(object sender, NetMQSocketEventArgs e)
        {
            byte[] data = m_serverSocket.Receive();

            IntPtr address;

            // checking if 64bit or 32 bit
            if (data.Length == 8)
            {
                address = new IntPtr(BitConverter.ToInt64(data, 0));
            }
            else
            {
                address = new IntPtr(BitConverter.ToInt32(data, 0));
            }

            GCHandle handle = GCHandle.FromIntPtr(address);

            Task task = (Task)handle.Target;

            TryExecuteTask(task);

            handle.Free();
        }
コード例 #34
0
ファイル: NetMQPoller.cs プロジェクト: awb99/netmq
 private void OnSocketEventsChanged(object sender, NetMQSocketEventArgs e)
 {
     // when the sockets SendReady or ReceiveReady changed we marked the poller as dirty in order to reset the poll events
     m_isPollSetDirty = true;
 }
コード例 #35
0
 void OnSend(object sender, NetMQSocketEventArgs e)
 {
     m_sendEvent.Fire(this, new NetMQActorEventArgs(this));
 }
コード例 #36
0
 void OnReceive(object sender, NetMQSocketEventArgs e)
 {
     m_receiveEvent.Fire(this, new NetMQActorEventArgs(this));
 }
コード例 #37
0
ファイル: MDPBroker.cs プロジェクト: romanros/netmq
        /// <summary>
        ///     expect from
        ///     CLIENT  ->  [sender adr][e][protocol header][service name][request]
        ///     WORKER  ->  [sender adr][e][protocol header][mdp command][reply]
        /// </summary>
        private void ProcessReceivedMessage (object sender, NetMQSocketEventArgs e)
        {
            var msg = e.Socket.ReceiveMultipartMessage ();

            DebugLog (string.Format ("Received: {0}", msg));

            var senderFrame = msg.Pop ();               // [e][protocol header][service or command][data]
            var empty = msg.Pop ();                     // [protocol header][service or command][data]
            var headerFrame = msg.Pop ();               // [service or command][data]
            var header = headerFrame.ConvertToString ();

            if (header == MDPClientHeader)
                ProcessClientMessage (senderFrame, msg);
            else
                if (header == MDPWorkerHeader)
                    ProcessWorkerMessage (senderFrame, msg);
                else
                    Log (string.Format ("ERROR - message with invalid protocol header!"));
        }
コード例 #38
0
 protected override void FrontendHandler(NetMQSocketEventArgs args)
 {
     Console.WriteLine("In forwarder" + args.ToString());
     this.FrontendSocket.Forward(this.BackendSocket);
 }
コード例 #39
0
ファイル: Program.cs プロジェクト: EugenDueck/netmq
        private static void RepOnReceiveReady(object sender, NetMQSocketEventArgs socket)
        {
            try
            {
                NetMQSocket rep = socket.Socket;

                bool hasMore;
                byte[] message = rep.Receive(SendReceiveOptions.DontWait, out hasMore);

                //Thread.Sleep(1000); //  Simulate 'work'

                byte[] response =
                    Encoding.Unicode.GetBytes(Encoding.Unicode.GetString(message) + " World from worker " + Encoding.Unicode.GetString(rep.Options.Identity));

                rep.Send(response, response.Length, SendReceiveOptions.DontWait);
            }
            catch (Exception exc)
            {
                Console.WriteLine("Exception on RepOnReceiveReady: {0}", exc.Message);
                throw;
            }
        }
コード例 #40
0
 private void OnReceive(object sender, NetMQSocketEventArgs e)
 {
     m_receiveEventDelegatorHelper.Fire(this, new NetMQActorEventArgs(this));
 }
コード例 #41
0
ファイル: NetMQProactor.cs プロジェクト: zredb/netmq
        private void OnSocketReady(object sender, NetMQSocketEventArgs e)
        {
            NetMQMessage message = m_receiveSocket.ReceiveMultipartMessage();

            m_handler(m_receiveSocket, message);
        }
コード例 #42
0
ファイル: Proxy.cs プロジェクト: liu7788414/netmq
 private void OnBackendReady(object sender, NetMQSocketEventArgs e)
 {
     ProxyBetween(m_backend, m_frontend, m_controlOut);
 }
コード例 #43
0
ファイル: Proxy.cs プロジェクト: somdoron/netmq
 private void OnFrontendReady(object sender, NetMQSocketEventArgs e)
 {
     ProxyBetween(m_frontend, m_backend, m_controlIn);
 }
コード例 #44
0
ファイル: Program.cs プロジェクト: GrabCAD/netmq
        /// <summary>
        ///     handles the ReceiveReady event
        ///
        ///     get the message and validates that the send data is correct
        ///     prints an appropriate message on screen in either way
        /// </summary>
        private static void OnClientReceiveReady(object sender, NetMQSocketEventArgs e)
        {
            var reply = e.Socket.ReceiveFrameBytes();
            var strReply = Encoding.Unicode.GetString(reply);

            if (Int32.Parse(strReply) == s_sequence)
            {
                Console.WriteLine("C: Server replied OK ({0})", strReply);

                s_retriesLeft = Commons.RequestClientRetries;
                s_expectReply = false;
            }
            else
            {
                Console.WriteLine("C: Malformed reply from server: {0}", strReply);
            }
        }
コード例 #45
0
ファイル: HistoricalDataServer.cs プロジェクト: leo90skk/qdms
        /// <summary>
        ///     This is called when a new historical data request or data push request is made.
        /// </summary>
        private void SocketReceiveReady(object sender, NetMQSocketEventArgs e)
        {
            string requesterIdentity;
            string text;

            lock (_socketLock)
            {
                // Here we process the first two message parts: first, the identity string of the client
                requesterIdentity = _socket?.ReceiveFrameString() ?? string.Empty;
                // Second: the string specifying the type of request
                text = _socket?.ReceiveFrameString() ?? string.Empty;
            }

            if (text.Equals(MessageType.HistRequest, StringComparison.InvariantCultureIgnoreCase)) // The client wants to request some data
            {
                AcceptHistoricalDataRequest(requesterIdentity);
            }
            else if (text.Equals(MessageType.HistPush, StringComparison.InvariantCultureIgnoreCase)) // The client wants to push some data into the db
            {
                AcceptDataAdditionRequest(requesterIdentity);
            }
            else if (text.Equals(MessageType.AvailableDataRequest, StringComparison.InvariantCultureIgnoreCase)) // Client wants to know what kind of data we have stored locally
            {
                AcceptAvailableDataRequest(requesterIdentity);
            }
            else
            {
                _logger.Info($"Unrecognized request to historical data broker: {text}");
            }
        }
コード例 #46
0
ファイル: ExchangeTests.cs プロジェクト: yonglehou/Daytona
 private void sub_ReceiveReady(object sender, NetMQSocketEventArgs e)
 {
     ReceiveReady = true;
 }
コード例 #47
0
ファイル: MDPClientAsync.cs プロジェクト: GrabCAD/netmq
        /// <summary>
        ///     handle the incoming messages
        ///     if a message is received timeout timer is reseted
        /// </summary>
        /// <remarks>
        ///     socket strips [client adr][e] from message // TODO remove this?!
        ///     message -> 
        ///                [empty frame][protocol header][service name][reply]
        ///                [empty frame][protocol header][service name][result code of service lookup]
        /// </remarks>
        private void OnProcessReceiveReady(object sender, NetMQSocketEventArgs e)
        {
            Exception exception = null;
            NetMQMessage reply = null;
            try
            {
                reply = m_client.ReceiveMultipartMessage();
                if (ReferenceEquals(reply, null))
                    throw new ApplicationException("Unexpected behavior");

                m_timer.EnableAndReset(); // reset timeout timer because a message was received

                Log($"[CLIENT INFO] received the reply {reply}");

                ExtractFrames(reply);
            }
            catch (Exception ex)
            {
                exception = ex;
            }
            finally
            {
                ReturnReply(reply, exception);
            }
        }
コード例 #48
0
 private void OnSocketEventsChanged(object sender, NetMQSocketEventArgs e)
 {
     // when the sockets SendReady or ReceiveReady changed we marked the poller as dirty in order to reset the poll events
     m_isPollSetDirty = true;
 }
コード例 #49
0
ファイル: NetMQProactor.cs プロジェクト: cjkao/netmq
        private void OnSocketReady(object sender, NetMQSocketEventArgs e)
        {
            NetMQMessage message = m_receiveSocket.ReceiveMultipartMessage();

            m_handler(m_receiveSocket, message);
        }
コード例 #50
0
ファイル: NetMQQueue.cs プロジェクト: aung2phyowai/netmq-uwp
 private void OnReceiveReady(object sender, NetMQSocketEventArgs e)
 {
     m_eventDelegator.Fire(this, new NetMQQueueEventArgs <T>(this));
 }
コード例 #51
0
 //called for each data set
 void getData(object sender, NetMQ.NetMQSocketEventArgs e)
 {
     msg = client.ReceiveMessage();
 }
コード例 #52
0
        private void OnShimMessage(object sender, NetMQSocketEventArgs e)
        {
            string command = e.Socket.ReceiveFrameString();

            if (command == NetMQActor.EndShimMessage)
            {
                m_poller.Cancel();
            }
            else if (command == SubscribeCommand)
            {
                string topic = e.Socket.ReceiveFrameString();
                m_subscriptions.Add(topic);

                if (m_subscriber != null)
                {
                    m_subscriber.Subscribe(topic);
                }
            }
        }
コード例 #53
0
 private void OnSend(object sender, NetMQSocketEventArgs e)
 {
     m_sendEventDelegatorHelper.Fire(this, new NetMQActorEventArgs(this));
 }
コード例 #54
0
        private void OnSubscriberMessage(object sender, NetMQSocketEventArgs e)
        {
            // we just forward the message to the actor
            var message = m_subscriber.ReceiveMultipartMessage();

            var topic = message[0].ConvertToString();

            if (topic == WelcomeMessage)
            {
                // TODO: disconnection has happend, we might want to get snapshot from server
            }
            else if (topic == HeartbeatMessage)
            {
                // we got a heartbeat, lets postponed the timer
                m_timeoutTimer.Enable = false;
                m_timeoutTimer.Enable = true;
            }
            else
            {
                m_shim.SendMultipartMessage(message);
            }
        }
コード例 #55
0
ファイル: NetMQBeacon.cs プロジェクト: wangkai2014/netmq
            private void OnPipeReady(object sender, NetMQSocketEventArgs e)
            {
                NetMQMessage message = m_pipe.ReceiveMultipartMessage();

                string command = message.Pop().ConvertToString();

                switch (command)
                {
                    case ConfigureCommand:
                        string interfaceName = message.Pop().ConvertToString();
                        int port = message.Pop().ConvertToInt32();
                        Configure(interfaceName, port);
                        break;
                    case PublishCommand:
                        m_transmit = message.Pop();
                        m_pingTimer.Interval = message.Pop().ConvertToInt32();
                        m_pingTimer.Enable = true;
                        SendUdpFrame(m_transmit);
                        break;
                    case SilenceCommand:
                        m_transmit = null;
                        m_pingTimer.Enable = false;
                        break;
                    case SubscribeCommand:
                        m_filter = message.Pop();
                        break;
                    case UnsubscribeCommand:
                        m_filter = null;
                        break;
                    case NetMQActor.EndShimMessage:
                        m_poller.Cancel();
                        break;
                    default:
                        throw new ArgumentOutOfRangeException();
                }
            }
コード例 #56
0
ファイル: Program.cs プロジェクト: huoxudong125/ZeroMqDemos
 void Client_ReceiveReady(object sender, NetMQSocketEventArgs e)
 {
     bool hasmore = false;
     e.Socket.Receive(out hasmore);
     if (hasmore)
     {
         string result = e.Socket.ReceiveString(out hasmore);
         Console.WriteLine("REPLY " + result);
     }
 }
コード例 #57
0
ファイル: Proxy.cs プロジェクト: Trading-Lab/ZeroMQ-for-.NET
 private void OnFrontendReady(object sender, NetMQSocketEventArgs e) => ProxyBetween(m_frontend, m_backend, m_controlIn);