/// <summary> /// Forwards replies from the backend socket to the frontend socket. /// </summary> protected override bool BackendHandler(ZSocket sock, out ZMessage message, out ZError error) { error = default(ZError); message = null; // receiving scope // DEALER: normal movemsg ZMessage incoming = null; if (!sock.ReceiveMessage(ref incoming, /* ZSocketFlags.DontWait */ ZSocketFlags.None, out error)) { return(false); } using (incoming) { // STREAM: write frames: identity, body, identity, empty // Read identity int ic = (int)incoming[0].Length; var identityBytes = new byte[ic]; incoming[0].Read(identityBytes, 0, ic); // Remove DEALER's delimiter incoming.RemoveAt(1); // Append Identity frame var identity0 = new ZFrame(identityBytes); incoming.Add(identity0); // Append STREAM's empty delimiter frame incoming.Add(new ZFrame()); if (!SendMsg(FrontendSocket, incoming, out error)) { return(false); } } return(true); }
public string Receive() { var msg = _socket.ReceiveMessage(); return(msg.PopString()); }
public static bool DefaultReceiveMessage(ZSocket socket, out ZMessage message, out ZError error) { message = null; return(socket.ReceiveMessage(ref message, out error)); }