當前位置: 首頁>>代碼示例>>C#>>正文


C# NetMQ.NetMQSocketEventArgs類代碼示例

本文整理匯總了C#中NetMQ.NetMQSocketEventArgs的典型用法代碼示例。如果您正苦於以下問題:C# NetMQSocketEventArgs類的具體用法?C# NetMQSocketEventArgs怎麽用?C# NetMQSocketEventArgs使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


NetMQSocketEventArgs類屬於NetMQ命名空間,在下文中一共展示了NetMQSocketEventArgs類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。

示例1: FrontendOnReceiveReady

        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());
            }
        }
開發者ID:EugenDueck,項目名稱:netmq,代碼行數:26,代碼來源:Program.cs

示例2: RepSocketOnReceiveReady

 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);
 }
開發者ID:benchremarked,項目名稱:spbexReactive,代碼行數:7,代碼來源:ReactiveServer.cs

示例3: OnReceiveMessage

		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 });
		}
開發者ID:BrannonKing,項目名稱:Kts.Remoting,代碼行數:7,代碼來源:NetMQSocketTransportSource.cs

示例4: ClientOnReceiveReady

        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);
        }
開發者ID:JayShelton,項目名稱:netmq,代碼行數:13,代碼來源:Program.cs

示例5: OnPipeReady

        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;
            }
        }
開發者ID:torshy,項目名稱:DotNetZyre,代碼行數:28,代碼來源:Chat.cs

示例6: BackendOnReceiveReady

        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);
            }
        }
開發者ID:EugenDueck,項目名稱:netmq,代碼行數:26,代碼來源:Program.cs

示例7: OnShimReady

 private void OnShimReady(object sender, NetMQSocketEventArgs e)
 {
     string command = e.Socket.ReceiveFrameString();
     if (command == NetMQActor.EndShimMessage)
     {
         m_poller.Stop();
     }
 }
開發者ID:cjkao,項目名稱:netmq,代碼行數:8,代碼來源:NetMQProactor.cs

示例8: SubscribeSocketOnReceiveReady

		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()));
			}
		}
開發者ID:jacob-adams,項目名稱:message-result-client,代碼行數:9,代碼來源:MessageHelper.cs

示例9: SubSocketOnReceiveReady

        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());
            }
        }
開發者ID:jacob-adams,項目名稱:message-result-client,代碼行數:10,代碼來源:ClientProgram.cs

示例10: WorkerOnReceiveReady

        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!"));
        }
開發者ID:EugenDueck,項目名稱:netmq,代碼行數:12,代碼來源:Program.cs

示例11: ClientOnReceiveReady

        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));
            }
        }
開發者ID:JayShelton,項目名稱:netmq,代碼行數:15,代碼來源:Program.cs

示例12: ClientOnReceiveReady

        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);
            }
        }
開發者ID:JayShelton,項目名稱:netmq,代碼行數:16,代碼來源:Program.cs

示例13: OnShimMessage

        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();
            }
        }
開發者ID:david-x-chen,項目名稱:ReliablePubSub,代碼行數:16,代碼來源:ReliableServer.cs

示例14: FrontendHandler

        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);
        }
開發者ID:yonglehou,項目名稱:Daytona,代碼行數:17,代碼來源:XForwarder.cs

示例15: SocketReceiveReady

 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");
     }
 }
開發者ID:buldo,項目名稱:MQExperiments,代碼行數:19,代碼來源:AsyncBrocker.cs


注:本文中的NetMQ.NetMQSocketEventArgs類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。