当前位置: 首页>>代码示例>>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;未经允许,请勿转载。