   (let* ((json-object-type 'plist)
          (json-msg (json-read-from-string msg))
          (buffer (plist-get json-msg :buffer))
-         (ip (plist-get json-msg :ip))
-         (dump-buffer (plist-get json-msg :dump_buffer)))
-    (cond (ip                           ; if given buffer and ip to connect to
-           (unless (find ip *emdocs-incoming-clients*
-                         :test #'emdocs-is-ip-from-client)
-             (add-to-list '*emdocs-incoming-clients*
-                          (make-instance 'emdocs-client
-                                         :process sock
-                                         :attached-buffer buffer
-                                         :ip ip))
-             ;; (emdocs-broadcast-buffer-at-intervals buffer sock)
-              (unless (find ip *emdocs-outgoing-clients*
-                           :test #'emdocs-is-ip-from-client)
-               (emdocs-connect-client buffer ip))
-              (emdocs-broadcast-message msg)))
-          (dump-buffer
-           (with-current-buffer buffer
-             (process-send-string sock (buffer-string))
-             (delete-process sock))))))
+         (ip (plist-get json-msg :ip)))
+    (unless (find ip *emdocs-incoming-clients*
+                  :test #'emdocs-is-ip-from-client)
+      (add-to-list '*emdocs-incoming-clients*
+                   (make-instance 'emdocs-client
+                                  :process sock
+                                  :attached-buffer buffer
+                                  :ip ip))
+      (unless (find ip *emdocs-outgoing-clients*
+                    :test #'emdocs-is-ip-from-client)
+        (emdocs-connect-client buffer ip))
+      (emdocs-broadcast-message msg))))
 
 (defun emdocs-setup-server (my-ip)
   "docstring"

                         (goto-char cur-point)
                         (delete-char content)))
                     (setq emdocs-is-network-insert nil))))))
            ;; (buffer-contents
            ;;  (with-current-buffer buffer
            ;;    (when emdocs-mode
            ;;      (let ((prev-point (point)))
            ;;        (setq emdocs-is-network-insert t)
            ;;        (unwind-protect
            ;;            (progn
            ;;              (goto-char cur-start)
            ;;              (if (= cur-start (point-min))
            ;;                  (erase-buffer))
            ;;              (insert buffer-contents)
            ;;              (goto-char prev-point))
            ;;          (setq emdocs-is-network-insert nil))))))
            ))))

(defun emdocs-connect-client (buffer ip)
  "docstring"
  (unless (string-equal ip (emdocs-get-internal-ip-address))
    (let ((process (make-network-process
                    :name (emdocs-get-client-process-name buffer ip)
                    :buffer (emdocs-get-client-process-buffer buffer)
                    :family 'ipv4
                    :host ip
                    :service +emdocs-http-port+
                    :sentinel (lambda (sock msg)
                                (emdocs-client-sentinel buffer sock msg))
                    :filter (lambda (sock msg)
                              (emdocs-client-filter buffer sock msg))
                    :server nil
                    :noquery t)))
      (add-to-list '*emdocs-outgoing-clients*
                   (make-instance 'emdocs-client
                                  :process process
                                  :attached-buffer (if (bufferp buffer)
                                                       (buffer-name buffer)
                                                     buffer)
                                  :ip ip))
      (with-current-buffer buffer
        (erase-buffer)
        (process-send-string
         (make-network-process
          :buffer buffer
          :family 'ipv4
          :host ip
          :service +emdocs-http-port+
          :server nil
          :noquery t)
         (json-encode `(:buffer ,buffer
                        :dump_buffer ,t)))))))

(defun emdocs-broadcast-message (msg)
  "docstring"

           (type (plist-get json-msg :edit_type))
           (cur-point (plist-get json-msg :point))
           (content (plist-get json-msg :content))
           (buffer-contents (plist-get json-msg :buffer_contents)))
      (cond (ip                       ; if being told to connect
             (unless (find ip *emdocs-outgoing-clients*
                           :test #'emdocs-is-ip-from-client)
               (emdocs-connect-client buffer ip)))
            (cur-point
             (with-current-buffer (emdocs-get-attached-buffer client)
               (when emdocs-mode
                 (save-excursion
                   (setq emdocs-is-network-insert t)
