diff --git a/example/websocket/websocket.el b/example/websocket/websocket.el new file mode 100644 index 0000000..04fc36a --- /dev/null +++ b/example/websocket/websocket.el @@ -0,0 +1,35 @@ +;; -*- coding: utf-8; lexical-binding: t; -*- + +(require 'websocket) + +(setq-local websocket-eldoc-callback nil) +(defun test-websocket-eldoc (callback) + (setq websocket-eldoc-callback + (if (compiled-function-p callback) callback nil))) +(set (make-local-variable 'eldoc-documentation-strategy) + 'eldoc-documentation-compose-eagerly) + +(run-with-timer 1 nil + (lambda () + (funcall websocket-eldoc-callback "hel"))) + +(test-websocket-eldoc "hel") + +(make-local-variable 'eldoc-documentation-functions) +(add-to-list 'eldoc-documentation-functions #'test-websocket-eldoc) + +(setq ws-server (websocket-server + 4000 + :host 'local + :on-message (lambda (ws frame) + (when (and (boundp 'websocket-eldoc-callback) (compiled-function-p websocket-eldoc-callback)) + (websocket-send-text ws (format "eldoc showed: %s" (websocket-frame-text frame))) + (funcall websocket-eldoc-callback (websocket-frame-text frame)))))) + +(funcall (symbol-value (obarray-get obarray "websocket-eldoc-callback")) "hello") + +(symbol-value 'websocket-eldoc-callback) + +(websocket-server-close ws-server) + +(funcall websocket-eldoc-callback "hello") diff --git a/example/websocket/websocket.html b/example/websocket/websocket.html new file mode 100644 index 0000000..0604799 --- /dev/null +++ b/example/websocket/websocket.html @@ -0,0 +1,9 @@ + + +
+ +