Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

got it to connect, but not to handshake correctly. I think I still

need to speak http
  • Loading branch information...
commit feeb8c24325a7515ce3d64537f9d55ec2eaf2fb6 1 parent df51fd7
@langmartin authored
Showing with 54 additions and 53 deletions.
  1. +54 −53 chrome-debugger.el
View
107 chrome-debugger.el
@@ -1,69 +1,70 @@
;;;; Interface functions are at the bottom.
-(defcustom chrome-debugger-host "localhost"
- "Hostname of the server running the ChromeDevTools"
- :group 'chrome-debugger
+(require 'json)
+
+(defcustom chrome-dev-tools-host "localhost"
+ "Hostname of the browser running the ChromeDevTools"
+ :group 'chrome-dev-tools
:type 'string)
-(defcustom chrome-debugger-port 9222
- "Port for the server running the ChromeDevTools"
- :group 'chrome-debugger
+(defcustom chrome-dev-tools-port 9222
+ "Port for the browser running the ChromeDevTools"
+ :group 'chrome-dev-tools
:type 'integer)
-(defvar chrome-debugger-buffer "*chrome debugger*"
- "Name of the chrome-debugger buffer")
+(defvar chrome-dev-tools-name "*chrome dev tools*"
+ "Name of the chrome-dev-tools network stream")
+
+(defvar chrome-dev-tools-buffer "*chrome dev tools*"
+ "Name of the chrome-dev-tools buffer")
+
+(defvar chrome-dev-tools-process nil)
-(defvar chrome-debugger-stream "*chrome debugger*"
- "Name of the chrome-debugger network stream")
+(setq crlf "\r\n")
-(defmacro with-chrome-debugger-repl (body)
+(defmacro with-chrome-dev-tools (&rest body)
`(save-excursion
- (let ((chrome-debugger-buffer (get-buffer chrome-debugger-buffer)))
- (if (null chrome-debugger-buffer)
- (open-network-stream
- chrome-debugger-stream
- chrome-debugger-buffer
- chrome-debugger-host
- chrome-debugger-port))
- (set-buffer chrome-debugger-buffer)
- ,@body)))
+ (if (not (and (processp chrome-dev-tools-process)
+ (process-live-p chrome-dev-tools-process)))
+ (setq chrome-dev-tools-process
+ (open-network-stream
+ chrome-dev-tools-name
+ chrome-dev-tools-buffer
+ chrome-dev-tools-host
+ chrome-dev-tools-port)))
+ (set-buffer (get-buffer chrome-dev-tools-buffer))
+ ,@body))
-(defun chrome-debugger-send* (str)
- "Send a literal string to chrome-debugger-process."
- (process-send-string chrome-debugger-stream str))
+(defun chrome-dev-tools-send* (&rest str)
+ "Send a literal string to chrome-dev-tools-process."
+ (mapc (lambda (str)
+ (process-send-string chrome-dev-tools-process str))
+ str))
-(defun chrome-debugger-send (cmd tool &optional dest)
+(defun chrome-dev-tools-send (cmd tool &optional dest)
"Send a command assuming the environment is set correctly."
- (chrome-debugger-send* "Content-Length: ")
- (chrome-debugger-send* (+ (length cmd) 2))
- (chrome-debugger-send* crlf)
- (chrome-debugger-send* "Tool: ")
- (chrome-debugger-send* tool)
- (chrome-debugger-send* crlf)
- (if (dest)
- (progn
- (chrome-debugger-send* "Destination: ")
- (chrome-debugger-send* dest)
- (chrome-debugger-send* crlf)))
- (chrome-debugger-send* crlf)
- (chrome-debugger-send* cmd))
+ (chrome-dev-tools-send*
+ "Content-Length: " (+ (length cmd) 2) crlf
+ "Tool: " tool crlf)
+ (if (dest)
+ (chrome-dev-tools-send*
+ "Destination: " dest crlf))
+ (chrome-dev-tools-send*
+ crlf cmd))
-(defun chrome-debugger-read* ()
- "Read a response assuming the environment is set correctly."
-
- )
+(defun chrome-dev-tools-reset ()
+ (when (processp chrome-dev-tools-process)
+ (delete-process chrome-dev-tools-process)
+ (kill-buffer chrome-dev-tools-buffer)))
-(defun chrome-debugger-handshake ()
+(defun chrome-dev-tools-startup ()
(interactive)
- (with-chrome-debugger-repl
- (let ((text "ChromeDevToolsHandshake"))
- (chrome-debugger-echo* text)
- (if (not (equal text (chrome-debugger-read*)))
- (error "handshake with the ChromeDevTools server failed.")
- t))))
+ (chrome-dev-tools-reset)
+ (with-chrome-dev-tools
+ (let ((handshake "ChromeDevToolsHandshake\r\n"))
+ (chrome-dev-tools-send* handshake)
+ (message "point at %d" (point))
+ (if (not (search-forward handshake (length handshake) t))
+ (error "handshake with the ChromeDevTools server failed.")))))
-(defun chrome-debugger-send (cmd)
- "Send a command, setting the environment"
- (interactive "sSend: ")
- (with-chrome-debugger-repl
- (chrome-debugger-send* cmd)))
+;; (chrome-dev-tools-startup)
Please sign in to comment.
Something went wrong with that request. Please try again.