                   (equal (emdocs-get-process client) sock))
                 *emdocs-incoming-clients*)))))
 
+(defun emdocs-broadcast-buffer-at-intervals (buffer sock)
+  "docstring"
+  (when (get-buffer buffer)
+    (with-current-buffer buffer
+      (when emdocs-mode
+        (process-send-string
+         sock
+         (json-encode `(:buffer ,buffer
+                        :buffer_contents ,(buffer-string))))
+        (run-at-time "1 min" nil
+                     #'emdocs-broadcast-buffer-at-intervals buffer sock)))))
+
 (defun emdocs-server-filter (sock msg)
   "docstring"
   ;; assumes will only receive json from emdocs-client-filter

  "docstring"
  :lighter " MDox"
  :keymap (let ((map (make-sparse-keymap)))
            (define-key map (kbd "C-c C-c") 'emdocs-mode)
            map)
  (if emdocs-mode
      (emdocs-connect (buffer-name))
    (emdocs-disconnect)))

(provide 'emdocs-mode)

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