コード例 #1
0
        public void Recv(Socket socket)
        {
            Queue <byte[]> receivedFrames = socket.RecvAll();

            while (receivedFrames.Count > 0)
            {
                frames.Insert(0, (receivedFrames.Dequeue()));
            }
        }
コード例 #2
0
 /// <summary>
 /// Prints all pending messages to the console.
 /// </summary>
 /// <param name="socket">ZMQ Socket</param>
 public static void Dump(Socket socket, Encoding encoding)
 {
     Console.WriteLine(new String('-', 38));
     foreach (byte[] msg in socket.RecvAll())
     {
         Console.Write("[{0}] ", String.Format("{0:d3}", msg.Length));
         if (msg.Length == 17 && msg[0] == 0)
         {
             Console.WriteLine(ZHelpers.DecodeUUID(msg).Substring(1));
         }
         else
         {
             Console.WriteLine(encoding.GetString(msg));
         }
     }
 }
コード例 #3
0
ファイル: zmsg.cs プロジェクト: hnkien/zguide2
        public void Recv(Socket socket)
        {
            Queue<byte[]> receivedFrames = socket.RecvAll();

            while (receivedFrames.Count > 0)
            {
                frames.Insert(0, (receivedFrames.Dequeue()));
            }
        }
コード例 #4
0
ファイル: Device.cs プロジェクト: rgl/clrzmq2
 protected override void FrontendHandler(Socket socket, IOMultiPlex revents)
 {
     Queue<byte[]> msgs = socket.RecvAll();
     messageProcessor(msgs.Dequeue(), msgs);
 }
コード例 #5
0
ファイル: Util.cs プロジェクト: Gohla/protophase
 /// <summary>
 /// Prints all pending messages to the console.
 /// </summary>
 /// <param name="socket">ZMQ Socket</param>
 public static void Dump(Socket socket, Encoding encoding)
 {
     Console.WriteLine(new String('-', 38));
     foreach (byte[] msg in socket.RecvAll()) {
         Console.Write("[{0}] ", String.Format("{0:d3}", msg.Length));
         if (msg.Length == 17 && msg[0] == 0)  {
             Console.WriteLine(ZHelpers.DecodeUUID(msg).Substring(1));
         } else {
             Console.WriteLine(encoding.GetString(msg));
         }
     }
 }
コード例 #6
0
        private void Handler(Socket socket, IOMultiPlex revents)
        {
            try
            {
                var id = socket.Recv();
                DiscardEmptyLine(socket);
                var datagram = socket.RecvAll(Encoding.UTF8);

                var request = _formatter.DeserializeRequest(datagram);

                _work(request, response => socket.SendDatagram(id, _formatter.Serialize(response)));
            }
            catch (Exception ex)
            {
                Console.ForegroundColor = ConsoleColor.Red;
                Console.WriteLine(ex.Message);
                Console.WriteLine(ex.StackTrace);
                Console.ForegroundColor = ConsoleColor.White;
            }
        }
コード例 #7
0
ファイル: Util.cs プロジェクト: paulcbetts/clrzmq
        /// <summary>
        /// Prints all pending messages to the console.
        /// </summary>
        /// <param name="socket">ZMQ Socket</param>
        /// <param name="encoding">Encoding to use for message decoding</param>
        public static void Dump(Socket socket, Encoding encoding)
        {
            if (socket == null) {
                throw new ArgumentNullException("socket");
            }

            Console.WriteLine(new String('-', 38));
            foreach (byte[] msg in socket.RecvAll()) {
                Console.Write("[{0}] ", String.Format("{0:d3}", msg.Length));
                if (msg.Length == 17 && msg[0] == 0) {
                    Console.WriteLine(DecodeUUID(msg).Substring(1));
                }
                else {
                    Console.WriteLine(encoding.GetString(msg));
                }
            }
        }
コード例 #8
0
ファイル: zmsg.cs プロジェクト: nivertech/zguide
        public void Recv(Socket socket)
        {
            Queue<byte[]> msgParts = socket.RecvAll();

            while (msgParts.Count > 0) {
                _msgParts.Insert(0, (msgParts.Dequeue()));
            }
        }
コード例 #9
0
        private void OnRequest(Socket socket, IOMultiPlex revents)
        {
            var message = socket.RecvAll(Encoding.UTF8).ToArray();
            if (message.First()!="RECALL") return;

            var from = Int64.Parse(message[1]);
            var to = message[2] == "ALL" ? Int64.MaxValue : Int64.Parse(message[2]);

            var ticks = LoopbackDevice.Retrieve(from, to);

            Send(socket, Encode(ticks));
        }
コード例 #10
0
 private void OnPost(Socket socket, IOMultiPlex revents)
 {
     var message = socket.RecvAll(Encoding.UTF8).ToArray();
     if (message[0] != "POST")
     {
         _log("Bad request [" + message[0] + "]");
         socket.Send("400 Bad Request", Encoding.UTF8);
         return;
     }
     _log("POST from " + message[1]);
     _sink.Publish(new Guid(message[2]), new Guid(message[3]), message[4]);
     socket.Send("202 ACCEPTED", Encoding.UTF8);
 }