   (with-current-buffer (emdocs-get-client-process-buffer buffer)
     (goto-char (point-min))
     (insert "sentinel:" msg)
-    (newline)))
+    (unless (bolp) (newline)))
+  (cond ((string-match "^give me buffer and ip\n$" msg)
+         (process-send-string
+          sock
+          (json-encode
+           `(:buffer ,(buffer-name buffer)
+             :ip ,(emdocs-get-internal-ip-address)))))))
 
 (defun emdocs-client-filter (buffer sock msg)
   "docstring"
+  ;; assumes will only receive json from emdocs-after-change-function
   (with-current-buffer (emdocs-get-client-process-buffer buffer)
     (goto-char (point-min))
     (insert "filter:" msg)
-    (newline))
-  (cond ((string-match "^give your ip and buffer\n$" msg)
-         (process-send-string sock
-          (json-encode `(:buffer ,(buffer-name buffer)
-                         :ip ,(emdocs-get-internal-ip-address)))))))
+    (unless (bolp) (newline)))
+  (let* ((json-object-type 'plist)
+         (json-msg (json-read-from-string msg)))
+    (with-current-buffer (plist-get json-msg :buffer)
+      (save-excursion
+        (setq emdocs-is-network-insert t)
+        (unwind-protect
+            (cond
+             ((string-equal "insert" (plist-get json-msg :edit_type))
+              (goto-char (plist-get json-msg :point))
+              (insert (plist-get json-msg :content)))
+             ((string-equal "delete" (plist-get json-msg :edit_type))
+              (goto-char (plist-get json-msg :point))
+              (delete-char (plist-get json-msg :content))))
+          (setq emdocs-is-network-insert nil))))))
 
 (defun emdocs-connect-client (buffer ip)
   "docstring"

           (not (eq (process-status *emdocs-server*) 'closed)))
      (delete-process *emdocs-server*))
  (setq *emdocs-server* nil))

;;; define mode


        do (when (and client
                      (not (eq client 'no-conn)))
             (delete-process client)))
  (makunbound 'emdocs-client-list)
  (remove-hook 'after-change-functions #'emdocs-after-change-function))

;;; interactives
(defun emdocs-kill-server ()
  "docstring"
  (interactive)
