diff --git a/ethersync.el b/ethersync.el index ac5ea39..8575685 100644 --- a/ethersync.el +++ b/ethersync.el @@ -80,7 +80,7 @@ "Send a keep-alive message." ;; only send if there is a current socket ;; and delete an active timer when there isn't a socket open - (message "heartbeat? %s" (ethersync-current-socket)) + (message "heartbeat?") (when (ethersync-current-socket) (wss-send "2") (message "heartbeat sent: %s" *etherpad-buffer*)) @@ -109,7 +109,8 @@ "Return currently active socket or set SOCKET as current." (when socket (setq ep--current-socket socket)) - (message "current socket: %s in buffer: %s" ep--current-socket *etherpad-buffer*)) + (message "current socket: set") + ep--current-socket) ;; setters @@ -287,7 +288,7 @@ (nth 2 changes)) (chars (car (last changes)))) - ;;(message "old length: %s new length: %s ops: %s chars: %s" old-length new-length ops chars) + (message "old length: %s new length: %s ops: %s" old-length new-length ops) (list old-length ops chars) ))) @@ -425,10 +426,13 @@ use let bindings for multiple connections." (parsec-collect* (parsec-re "[0-9]+") (parsec-many-s (parsec-any-ch)))))) (message "frame: %s" (length fr0)) + (when (= 2 (length fr0)) + (message "frame: %s" fr0)) (pcase (car frp) ("0" (ethersync--parse-0 frp)) ("2" (ethersync--parse-2 frp)) ("3" (message "3: keep-alive")) + ("40" (message "40: comment")) ("42" (ethersync--parse-42 frp)) )))) diff --git a/notes/etherpad-protocol.org b/notes/etherpad-protocol.org index 495ef0a..c314cf6 100644 --- a/notes/etherpad-protocol.org +++ b/notes/etherpad-protocol.org @@ -28,7 +28,9 @@ see https://blog.abrochard.com/websockets.html and [[https://github.com/ahyatt/ * protocol, probes & partials -browser client sends url with pad name to server (e.g. https://etherpad.wikimedia.org/p/test ) establishes session (sid) and receives token (in cookie data). updates, changes & pad metadata are sent via wss connection. (e.g. wss://etherpad.wikimedia.org/socket.io/?EIO=3&transport=websocket&sid=Ap47gBZD98dHcW38AoqY ) +browser client sends url with pad name to server (e.g. https://etherpad.wikimedia.org/p/test ) establishes session (sid) and receives token (in cookie data). updates, changes & pad metadata are sent via wss connection. + +e.g. =wss://etherpad.wikimedia.org/socket.io/?EIO=3&transport=websocket&sid=Ap47gBZD98dHcW38AoqY= ** overview @@ -56,12 +58,11 @@ note right: COLLABROOM == keep-alive == client -> ep_server: 2 ep_server --> client: 3 - #+END_SRC #+CAPTION: overview of etherpad/easysync protocol #+ATTR_ORG: :width 400 -#+ATTR_LaTeX: :height 15cm :placement [!h] +#+ATTR_LaTeX: :height 15cm :placement [H] [[file:proto-x1.png]] ** comment plugin @@ -95,24 +96,25 @@ title comments #+CAPTION: comments #+ATTR_ORG: :width 400 -#+ATTR_LaTeX: :height 15cm :placement [!h] +#+ATTR_LaTeX: :height 15cm :placement [H] [[file:proto-x2.png]] ** example messages *init/request* -#+BEGIN_SRC text +#+BEGIN_SRC 40/comment, 42/comment,0["getComments",{"padId":"test"}] 42/comment,1["getCommentReplies",{"padId":"test"}] - 43/comment,0[{"comments":{"c-4U2BW8J2Lp0r68ZL":{"author":"a.0iRJZx7jiOAxVNMP","name":"zzkt","text":"yes","timestamp":1607769834917}}}] + +43/comment,0[{"comments":{"c-4U2BW8J2Lp0r68ZL":{"author":"a.0iRJZx7jiOAxVNMP","name":"zzkt","text":"yes","timestamp":1607769834917}}}] 43/comment,1[{"replies":{}}] #+END_SRC *updates (new)* -#+BEGIN_SRC text +#+BEGIN_SRC 42/comment,["pushAddCommentReply","c-reply-vMSgWSY4bFhaCCLR",{"commentId":"c-4U2BW8J2Lp0r68ZL","text":"no","changeTo":null,"changeFrom":null,"author":"a.0iRJZx7jiOAxVNMP","name":"zzkt","timestamp":1607770300230,"replyId":"c-reply-vMSgWSY4bFhaCCLR"}] 42/comment,2["getCommentReplies",{"padId":"test"}] @@ -121,14 +123,15 @@ title comments #+END_SRC *updates (changes)* -#+BEGIN_SRC text +#+BEGIN_SRC 42/comment,["textCommentUpdated","c-reply-vMSgWSY4bFhaCCLR","not yet"] #+END_SRC *updates (deletion)* -#+BEGIN_SRC text +#+BEGIN_SRC 42/comment,["commentDeleted","c-4U2BW8J2Lp0r68ZL"] - 42["message",{"type":"COLLABROOM","data":{"type":"NEW_CHANGES","newRev":234,"changeset":"Z:e>0=7*0=4$","apool":{"numToAttrib":{"0":["comment","comment-deleted"]},"attribToNum":{"comment,comment-deleted":0},"nextNum":1},"author":"a.0iRJZx7jiOAxVNMP","currentTime":1607770511397,"timeDelta":null}}] + +42["message",{"type":"COLLABROOM","data":{"type":"NEW_CHANGES","newRev":234,"changeset":"Z:e>0=7*0=4$","apool":{"numToAttrib":{"0":["comment","comment-deleted"]},"attribToNum":{"comment,comment-deleted":0},"nextNum":1},"author":"a.0iRJZx7jiOAxVNMP","currentTime":1607770511397,"timeDelta":null}}] #+END_SRC @@ -165,7 +168,7 @@ If we separate out the operations and convert the numbers to base 10, we get: Here are descriptions of the operations, where capital letters are variables: -#+BEGIN_SRC text +#+BEGIN_SRC ":N" : Source text has length N (must be first op) ">N" : Final text is N (positive) characters longer than source text (must be second op) " network/ws/messages/console/log etc + - Firefox/Chrome/Safari → network/ws/messages/console/log etc - =git clone https://github.com/guyzmo/PyEtherpadLite= - wscat - netcat @@ -458,8 +461,7 @@ example/reduced #+END_SRC - -#+BEGIN_SRC shell +#+BEGIN_SRC ❯ wscat -c "wss://example.org/socket.io/?EIO=3&transport=websocket" Connected (press CTRL+C to quit) < 0{"sid":"6_TVij3sJug26KFLAAGc","upgrades":[],"pingInterval":25000,"pingTimeout":5000} @@ -467,7 +469,7 @@ example/reduced > #+END_SRC -#+BEGIN_SRC js +#+BEGIN_SRC [ "message", { diff --git a/notes/etherpad-protocol.pdf b/notes/etherpad-protocol.pdf new file mode 100644 index 0000000..8b3a943 Binary files /dev/null and b/notes/etherpad-protocol.pdf differ