;;; Copyright © 2016 David Thompson <davet@gnu.org>
;;; Copyright © 2017 Christopher Allan Webber <cwebber@dustycloud.org>
;;; Copyright © 2019, 2020 Jan (janneke) Nieuwenhuizen <janneke@gnu.org>
+;;; Copyright © 2020 Rutger van Beusekom <rutger.van.beusekom@gmail.com>
;;;
;;; This file is part of guile-websocket.
;;;
(url #:getter .url #:init-value #f #:init-keyword #:url)
(uri #:accessor .uri #:init-value #f #:init-keyword #:uri)
(entropy-port #:accessor .entropy-port #:init-form (open-entropy-port))
+ (frames #:accessor .frames #:init-value '())
(on-close #:init-keyword #:on-close
#:init-value no-op
(cons frame (loop end)))))))
(define-method (websocket-send (websocket <websocket>) message data)
- (catch #t ; expect: wrong-type-arg (open port), system-error
+ (catch #t ; expect: wrong-type-arg (open port), system-error
(lambda _
- (let* ((frames (make-fragmented-frames data)))
- (let loop ((frames frames) (written '(nothing)))
- (when (pair? frames)
- (write-frame (car frames) (.socket websocket))
- (loop (cdr frames) (cons (car frames) written))))))
+ (let* ((frames (make-fragmented-frames data))
+ (frames? (pair? (.frames websocket))))
+ (set! (.frames websocket) (append (.frames websocket) frames))
+ (unless frames?
+ (let loop ()
+ (let ((frames (.frames websocket)))
+ (when (pair? frames)
+ (write-frame (car frames) (.socket websocket))
+ (set! (.frames websocket) (cdr (.frames websocket)))
+ (loop)))))))
(lambda (key . args)
(unless (and (memq key '(system-error wrong-type-arg))
(match args