aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTeddy Wing2021-02-03 20:21:03 +0100
committerTeddy Wing2021-02-03 20:21:03 +0100
commit074b4375a54e4bbf4539d37b1418eacb2a70f87a (patch)
treedd8f6eab2cf96188fc95ec92ff35249cfee654f6
parentb5c2f3a6ed194245e9c584f25b28d8f7c8f90218 (diff)
downloadextreload-074b4375a54e4bbf4539d37b1418eacb2a70f87a.tar.bz2
main: Get WebSocket URL from command line for `*client*`
Keep the `*client*` global variable, but use the client in `config`, constructed from the WebSocket URL passed from the command line. Not a huge fan of the global variable, but it's way easier to keep it like this rather than passing the client down to the `attach-to-target` and `reload-extension` functions.
-rw-r--r--l/src/config.lisp1
-rw-r--r--l/src/main.lisp17
2 files changed, 9 insertions, 9 deletions
diff --git a/l/src/config.lisp b/l/src/config.lisp
index eb8bede..4e3cbbf 100644
--- a/l/src/config.lisp
+++ b/l/src/config.lisp
@@ -16,6 +16,7 @@
:documentation "True if the current tab should be reloaded")
(ws-client
+ :reader ws-client
:documentation "WebSocket client")))
(defmethod print-object ((object config) stream)
diff --git a/l/src/main.lisp b/l/src/main.lisp
index a84e0cd..caadfe3 100644
--- a/l/src/main.lisp
+++ b/l/src/main.lisp
@@ -1,7 +1,5 @@
(in-package :extreload)
-(defvar *client* (wsd:make-client "ws://127.0.0.1:55755/devtools/browser/20c6f8a1-6540-4226-a876-44b72c176ad5"))
-
(defvar *wg* (wait-group:make-wait-group))
(opts:define-opts
@@ -21,17 +19,18 @@
(defun main ()
(let ((config (parse-options)))
- (format t "~a~%" config))
+ ;; Store the WebSocket client as a global.
+ (defvar *client* (ws-client config))
;; TODO: error if no `socket-url`
- (with-websocket-connection (*client*)
- (wsd:on :message *client* #'ws-on-message)
- ; (wsd:on :message *client* #'(lambda (message) (ws-on-message message)))
- ;; TODO: Maybe defvar *config* and store client in the config
+ (with-websocket-connection (*client*)
+ (wsd:on :message *client* #'ws-on-message)
+ ; (wsd:on :message *client* #'(lambda (message) (ws-on-message message)))
+ ;; TODO: Maybe defvar *config* and store client in the config
- (websocket-send *client* (target-get-targets-msg 1))
+ (websocket-send *client* (target-get-targets-msg 1))
- (wait-group:wait *wg*)))
+ (wait-group:wait *wg*))))
(defun ws-on-message (message)
(let* ((response (jsown:parse message))