From 7bdbd47eabd4be7d7905558e51369e0f346eb9ef Mon Sep 17 00:00:00 2001 From: Hugo Thunnissen Date: Wed, 17 Oct 2018 11:12:55 +0200 Subject: [PATCH] Change dir structure and add README --- README.md | 4 ++++ examples/run-process.el | 21 ++++++++++++++++++ run-process.el | 20 ----------------- stomp.el | 4 +++- test.el => test/test.el | 2 +- .../testdata}/multiple_frames.txt | Bin {testdata => test/testdata}/stomp_frame.txt | Bin .../testdata}/stomp_frame_cr.txt | Bin 8 files changed, 29 insertions(+), 22 deletions(-) create mode 100644 README.md create mode 100644 examples/run-process.el delete mode 100644 run-process.el rename test.el => test/test.el (97%) rename {testdata => test/testdata}/multiple_frames.txt (100%) rename {testdata => test/testdata}/stomp_frame.txt (100%) rename {testdata => test/testdata}/stomp_frame_cr.txt (100%) diff --git a/README.md b/README.md new file mode 100644 index 0000000..ef70156 --- /dev/null +++ b/README.md @@ -0,0 +1,4 @@ +# Stomp.el - STOMP in elisp +This is a small elisp library with functions for parsing, recieving, +composing and sending STOMP frames. The functions can be used in +combination with emacs processes to recieve and send frames. diff --git a/examples/run-process.el b/examples/run-process.el new file mode 100644 index 0000000..588f92a --- /dev/null +++ b/examples/run-process.el @@ -0,0 +1,21 @@ +(require 'map) +(load-file "/home/hugo/projects/stomp/stomp.el") + +;; (setq proc (make-process +;; :name "stomp-client" +;; :buffer "Barry" +;; :command "nc localhost 61613" +;; :filter (stomp-filter-function (lambda (frame) (frame "%s" frame))))) + +(setq proc (make-network-process + :name "stomp-client" + :buffer "stomp-frames" + :host "127.0.0.1" + :service 61613 + :filter (stomp-filter-function (lambda (frame) (message "%s" frame))))) + +(setq frame ()) +(stomp-send-frame proc (map-put frame 'command "CONNECT")) +(stomp-send-frame proc '((command . "SUBSCRIBE") (headers ("destination" . "/queue/testing")))) + + diff --git a/run-process.el b/run-process.el deleted file mode 100644 index 76ba00a..0000000 --- a/run-process.el +++ /dev/null @@ -1,20 +0,0 @@ -(require 'map) -(load-file "/home/hugo/projects/stomp/stomp.el") - -;; (setq proc (make-process -;; :name "stomp-client" -;; :buffer "Barry" -;; :command "nc localhost 61613" -;; :filter (stomp-filter-function (lambda (message) (message "%s" message))))) - -(setq proc (make-network-process - :name "stomp-client" - :buffer "stomp-messages" - :host "127.0.0.1" - :service 61613 - :filter (stomp-filter-function (lambda (message) (message "%s" message))))) - -(setq message ()) -(stomp-send-message proc (map-put message 'command "CONNECT")) - - diff --git a/stomp.el b/stomp.el index cc671ef..7f046f0 100644 --- a/stomp.el +++ b/stomp.el @@ -3,7 +3,6 @@ (require 'map) -;; TODO: make this send more than just the command (defun stomp-send-frame (process frame) "Send a message to a STOMP process" (process-send-string process (stomp-frame-to-string frame))) @@ -49,6 +48,7 @@ (map-put frame 'command (current-word)) (map-put frame 'headers (stomp-read-headers buffer headers-end-point)) ;; TODO: take content-length header into account + ;; This is might be hard to do if the content contains carriage returns. (map-put frame 'content (buffer-substring (+ 1 headers-end-point) frame-end-point))) (t nil))))) @@ -95,3 +95,5 @@ (alist-get 'command frame) (mapconcat (lambda (h) (format "%s:%s\n" (car h) (cdr h))) headers "") content))) + +(provide 'stomp) diff --git a/test.el b/test/test.el similarity index 97% rename from test.el rename to test/test.el index 4a2ef20..f3d44d1 100755 --- a/test.el +++ b/test/test.el @@ -10,7 +10,7 @@ (defun stomp-frame-buffer (test-file) "Create a buffer with a stomp frame in it for testing purposes" - (find-file (format "%s/testdata/%s" cwd test-file))) + (find-file (format "%s/test/testdata/%s" cwd test-file))) (defun simple-frame-buffer () "Simple buffer to be used for testing" diff --git a/testdata/multiple_frames.txt b/test/testdata/multiple_frames.txt similarity index 100% rename from testdata/multiple_frames.txt rename to test/testdata/multiple_frames.txt diff --git a/testdata/stomp_frame.txt b/test/testdata/stomp_frame.txt similarity index 100% rename from testdata/stomp_frame.txt rename to test/testdata/stomp_frame.txt diff --git a/testdata/stomp_frame_cr.txt b/test/testdata/stomp_frame_cr.txt similarity index 100% rename from testdata/stomp_frame_cr.txt rename to test/testdata/stomp_frame_cr.txt