        sock
        (concat
         (json-encode
-         `(:buffer ,(if (bufferp buffer)
-                        (buffer-name buffer)
-                      buffer)
+         `(:buffer ,(emdocs-get-attached-buffer buffer)
            :ip ,(emdocs-get-internal-ip-address)))
         "\n"))
     (let* ((json-object-type 'plist)

                           :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)

                         (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)
