José Romero avatar José Romero committed f29899f

Small semantic tweak, make ws-write handle binary frames properly.

Comments (0)

Files changed (1)

          ((< L `(** 2 16)) (wr 126) (wr (>> 8 L)) (wr (& L 255)))
          ((< L `(** 2 64)) (wr 127) (for X 8 (wr (& 255 (>> (* 8 (- 8 X)) L)))))
          (T (bye)) ) )
-   (prin Msg)
+   (cond
+      ((sym? Msg) (prin Msg))
+      ((and (lst? Msg) (num? (car Msg))) (apply wr Msg) )
+      ((and (lst? Msg) (sym? (car Msg))) (prin Msg) )
+      (T (quit "Bad message data")) )
    (flush) )
 
 (de ws-send @
    (ws-write 1 T (pass pack)) )
 
 (de ws-handshake ()
-   (task *Sock) # Disable the other protocols
    (and
       (= (lowc (pack (cdr (assoc "upgrade" *Headers)))) "websocket") 
       (sub? "upgrade" (lowc (pack (cdr (assoc "connection" *Headers))))) 
                (prinl "Upgrade: websocket^M")
                (prinl "Sec-WebSocket-Accept: " (line) "^M")
                (prinl "^M") ) )
-         T ) ) )
+         T )
+      (task *Sock) ) ) # Disable the other protocols
 
 # Start listening to websocket events
 (de ws-start ()
          (let F (ws-frame)
             (case (pop 'F)
                (8 (bye))
-               (9 (out *Sock (ws-write 10 (pop 'F) (pack F))))
+               (9 (out *Sock (ws-write 10 (pop 'F) F)))
                (0
                   (setq *WsFin (pop 'F))
                   (if *WsOpcode (conc *WsPayload F)) )
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.