       (if ip ; if being told to connect
           (unless (find ip *emdocs-outgoing-clients*
                         :test #'emdocs-is-ip-from-client)
-            (emdocs-connect-client (plist-get json-msg :buffer)
-                                   (plist-get json-msg :ip)))
+            (emdocs-connect-client buffer ip))
         (with-current-buffer buffer
           (save-excursion
             (setq emdocs-is-network-insert t)

                ((= beg end)
                 (emdocs-emit-keypress-json
                  buffer "delete" beg prev-length)))))))

(defvar-local emdocs-initial-client nil
  "docstring")

(defvar-local emdocs-ip-addr nil
  "docstring")

(defvar-local emdocs-is-network-insert nil
  "docstring")

(defvar-local emdocs-after-change-lambda nil
  "docstring")

(defun emdocs-attach-sockets-to-buffer (buffer ip)
  "docstring"

(defvar *emdocs-incoming-clients* nil
  "docstring")

;;; locals

(defvar-local emdocs-initial-client nil
  "docstring")

(defvar-local emdocs-ip-addr nil
  "docstring")

(defvar-local emdocs-is-network-insert nil
  "docstring")

(defvar-local emdocs-after-change-lambda nil
  "docstring")

;;; classes

(defclass emdocs-client ()
  ((process
    :initarg :process
    :accessor emdocs-get-process
    :documentation "docstring")
   (attached-buffer
    :initarg :attached-buffer
    :accessor emdocs-get-attached-buffer
    :documentation "docstring")
   (ip
    :initarg :ip
    :accessor emdocs-get-ip
    :documentation "docstring"))
  "docstring")

;;; functions

(defun emdocs-get-internal-ip-address (&optional device-name)
  "Returns ip address of active network interface, ignoring loopback. Returns
nil if none active. Returns an arbitrary interface if more than one is
connected."
  (if device-name
      (format-network-address (car (network-interface-info device-name)) t)
    (let ((network-interfaces (network-interface-list)))
