   (loop for client in *emdocs-incoming-clients*
         do (when (emdocs-test-if-client-attached-to-buffer client)
              (delete-process (emdocs-get-process client))))
-  (setq *emdocs-incoming-clients*
+  (setq *emdocs-incoming-clientbuffer
         (remove-if #'emdocs-test-if-client-attached-to-buffer
                    *emdocs-incoming-clients*))
   (setq-local after-change-functions

               (emdocs-connect-client buffer ip)))
            (cur-point
             (with-current-buffer buffer
               (save-excursion
                 (setq emdocs-is-network-insert t)
                 (unwind-protect
                     (cond
                      ((string-equal "insert" type)
                       (goto-char cur-point)
                       (insert content))
                      ((string-equal "delete" type)
                       (goto-char cur-point)
                       (delete-char content)))
                   (setq emdocs-is-network-insert nil)))))
            (buffer-contents
             (with-current-buffer buffer
               (let ((prev-point (point)))
                 (setq emdocs-is-network-insert t)
                 (unwind-protect
                     (progn
                       (goto-char (point-min))
                       (erase-buffer)
                       (insert buffer-contents)
                       (goto-char prev-point))
                   (setq emdocs-is-network-insert nil)))))))))

(defun emdocs-ask-for-buffer-contents (buffer sock)
  "docstring"
  (when (process-live-p sock)
    (process-send-string
     sock
     (json-encode `(:get_buffer_contents ,t
                    :buffer ,(if (bufferp buffer)
                                 (buffer-name buffer)
                               buffer))))
    (run-at-time "1 min" nil #'emdocs-ask-for-buffer-contents buffer sock)))

(defun emdocs-connect-client (buffer ip)
  "docstring"

   (emdocs-get-attached-buffer client)
   (buffer-name)))

(defun emdocs-disconnect (buffer)
  "docstring"
  (loop for client in *emdocs-outgoing-clients*
        do (when (emdocs-test-if-client-attached-to-buffer client)
