Commit 22b789fc authored by Ludovic Courtès's avatar Ludovic Courtès
Browse files

messages: 'message-parts' accepts #f as the recipient.

* jupyter/messages.scm (message-parts): Allow #:recipients to be #f.
parent 3b418494
......@@ -122,7 +122,7 @@ with KEY, another string."
(recipient (and=> (message-parent-header message)
header-sender)))
"Return the list of parts (bytevectors) of MESSAGE for RECIPIENT, a ZeroMQ
identity (a bytevector).
identity (a bytevector) of #f if there's no specific recipient.
This is a low-level procedure for internal use."
(let* ((header (header->string (message-header message)))
......@@ -133,11 +133,16 @@ This is a low-level procedure for internal use."
(content (message-content message))
(payload (string-append header parent metadata content))
(signature (get-signature key payload)))
(cons* recipient DELIM
(map string->utf8
(list signature
header parent
metadata content)))))
;; Per
;; <https://jupyter-client.readthedocs.io/en/latest/messaging.html#the-wire-protocol>,
;; the identities part before DELIM "can be zero or more socket
;; identities". Here we accept zero or one.
`(,@(if recipient (list recipient) '())
,DELIM
,@(map string->utf8
(list signature
header parent
metadata content)))))
(define (reply message type content)
"Return a Jupyter message that is a reply to MESSAGE."
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment