public void Recv(Socket socket) { Queue <byte[]> receivedFrames = socket.RecvAll(); while (receivedFrames.Count > 0) { frames.Insert(0, (receivedFrames.Dequeue())); } }
/// <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)); } } }
public void Recv(Socket socket) { Queue<byte[]> receivedFrames = socket.RecvAll(); while (receivedFrames.Count > 0) { frames.Insert(0, (receivedFrames.Dequeue())); } }
protected override void FrontendHandler(Socket socket, IOMultiPlex revents) { Queue<byte[]> msgs = socket.RecvAll(); messageProcessor(msgs.Dequeue(), msgs); }
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; } }
/// <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)); } } }
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)); }
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); }