예제 #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));
         }
     }
 }
        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()));
            }
        }
        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);
 }