fukamachi / websocket-driver

WebSocket server/client implementation for Common Lisp
BSD 2-Clause "Simplified" License
104 stars 28 forks source link

fix Commit https://github.com/fukamachi/websocket-driver/commit/228efcae0833a567fe446a5be8b573f9099ca0a6 #65

Closed anranyicheng closed 4 months ago

anranyicheng commented 4 months ago

hi, the commit https://github.com/fukamachi/websocket-driver/commit/228efcae0833a567fe446a5be8b573f9099ca0a6 is not considerate, restored it to the previous state and optimized

fukamachi commented 4 months ago

Thanks!

SuperDisk commented 4 months ago

What does this change actually do? This definitely performs a lot better than before, it's such a coincidence that this change got put in now, since I was doing some profiling on the stuff and was wondering why things were so slow-- I remembered that sleep call and came to check it out and mysteriously it had disappeared. Then I noticed that this PR got merged literally hours ago :)

anranyicheng commented 4 months ago

What does this change actually do? This definitely performs a lot better than before, it's such a coincidence that this change got put in now, since I was doing some profiling on the stuff and was wondering why things were so slow-- I remembered that sleep call and came to check it out and mysteriously it had disappeared. Then I noticed that this PR got merged literally hours ago :)

If it is an encrypted connection, an error will be reported when the server closes the connection, for example

(ql:quickload '(websocket-driver-client cl-base64))
(defparameter *client* 
  (wsd::make-client "wss://stream.bitget.fit/public/v1/stream?compress=true&terminalType=1"))
(wsd:on :open *client*
        (lambda ()
          (format *error-output* "~&connected~%")))

(wsd:on :close *client*
        (lambda (&key code reason)
          (format *error-output* "~&connection closed code:~a reason:~a~%"
                  code reason)))
(wsd:on :message *client*
        (lambda (message)
          (format t "~&received: ~a~%" (cl-base64::usb8-array-to-base64-string message))))

(wsd:start-connection *client*)
(wsd:send *client* 
      "{'op':'subscribe','args':[{'channel':'marginPrice','instType':'mc','instId':'default'}]}" )

After the connection is established and data transmission begins, the server will automatically close the connection after a few minutes, and an error will be reported when the connection is closed.