@@ -193,6 +193,19 @@ Call the next method if ARGS does not contain :server."
193
193
(jupyter-run-with-io pub
194
194
(jupyter-publish 'reauthenticate ))))
195
195
196
+ (defvar jupyter-server-kernel-frame-acc " " )
197
+
198
+ (defun jupyter-server-kernel-parse-frame (frame )
199
+ " Accumulate the WebSocket frame data and return the full response when complete.
200
+ Return nil if the frame is not yet complete."
201
+ (let ((payload (websocket-frame-payload frame)))
202
+ (setq jupyter-server-kernel-frame-acc (concat jupyter-server-kernel-frame-acc payload))
203
+ (if (websocket-frame-completep frame)
204
+ (let ((full-response jupyter-server-kernel-frame-acc))
205
+ (setq jupyter-server-kernel-frame-acc " " )
206
+ full-response)
207
+ nil )))
208
+
196
209
(cl-defmethod jupyter-websocket-io ((kernel jupyter-server-kernel))
197
210
" Return a list representing an IO connection to KERNEL.
198
211
The list is composed of two elements (IO-PUB ACTION-SUB), IO-PUB
@@ -274,16 +287,16 @@ this case FN will be evaluated on KERNEL."
274
287
; ; TODO: on-error publishes to status-pub
275
288
:on-message
276
289
(lambda (_ws frame )
277
- (pcase (websocket-frame-opcode frame)
278
- (( or 'text 'binary )
279
- ( let ((msg (jupyter-read-plist-from-string
280
- (websocket-frame-payload frame) )))
281
- (jupyter-run-with-io kernel-io
282
- (jupyter-publish (cons 'message msg)))))
283
- (_
284
- (jupyter-run-with-io status-pub
285
- (jupyter-publish
286
- (list 'error (websocket-frame-opcode frame))))))))))
290
+ (when-let ((response (jupyter-server-kernel-parse-frame frame)) )
291
+ (pcase (websocket-frame-opcode frame )
292
+ ((or 'text 'binary 'continuation )
293
+ ( let ((msg (jupyter-read-plist-from-string response )))
294
+ (jupyter-run-with-io kernel-io
295
+ (jupyter-publish (cons 'message msg)))))
296
+ (_
297
+ (jupyter-run-with-io status-pub
298
+ (jupyter-publish
299
+ (list 'error (websocket-frame-opcode frame) ))))))))))
287
300
(ws (prog1 (funcall make-websocket)
288
301
(jupyter-run-with-io reauth-pub
289
302
(jupyter-subscribe
0 commit comments