Created
August 7, 2013 20:45
-
-
Save tazjin/6178474 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| (defun zeph-message-json (message-id receiver-id method-name &optional args) | |
| "Creates the JSON array for a Zephyros message" | |
| (json-encode `(,message-id ,receiver-id ,method-name ,(if args args)))) | |
| (defun zeph-send-msg (receiver-id method-name &optional args) | |
| "Sends a message to the Zephyros connection and return the | |
| message ID. The ID will always be an integer, if a string | |
| is returned an error has occured." | |
| (let* ((zephconn (get-process "zephconn")) | |
| (msg-id (get-next-msg-id)) | |
| (msg-json (zeph-message-json msg-id | |
| receiver-id | |
| method-name | |
| args)) | |
| (msg-length (number-to-string (length msg-json))) | |
| (payload (concat msg-length "\n" msg-json ))) | |
| (if (eq (process-status (get-process "zephconn")) 'open) | |
| (progn (process-send-string (get-process "zephconn") payload) | |
| msg-id) | |
| "zeph.el: Connection is not open" | |
| ) | |
| msg-id)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment