master
Avril 6 years ago
parent 89da4c3668
commit 97fce06c4c
Signed by: flanchan
GPG Key ID: 284488987C31F630

@ -29,13 +29,18 @@ Functions:
; :binary - pointer to memory (see struct pointer in `pointer.lisp') ; :binary - pointer to memory (see struct pointer in `pointer.lisp')
; :close - A request to close (the message is always NIL for this type) ; :close - A request to close (the message is always NIL for this type)
;; If an error or message callback returns NIL, the listener is stopped (you still have to call sipc:release()). Otherwise, the return is ignored. ;; If an error or message callback returns NIL, the listener is stopped (you still have to call sipc:release()). Otherwise, the return is ignored.
sipc:respond(message value &optional type) ;; send response (note: only valid when handling message) works the same as send() (see below) with additional error responses:
;; t - success
;; :response-disabled - SI_NORESP flag was set
;; :response-invalid - this message cannnot be responded to like this
;; :response-multi - a response has already been sent
(sipc:with-bound-socket (socket-name socket-filename) (sipc:with-bound-socket (socket-name socket-filename)
body) body)
;; Bind socket from `socket-filename' to new lexical variable `socket-name' and run (progn @body), then relase the socket afterwards. If the socket fails to bind, return nil and do not attempt to execute body. ;; Bind socket from `socket-filename' to new lexical variable `socket-name' and run (progn @body), then relase the socket afterwards. If the socket fails to bind, return nil and do not attempt to execute body.
;; Add `:connect' after socket-filename to connect instead of binding. ;; Add `:connect' after socket-filename to connect instead of binding.
;client functions ;client functions
sipc:connect(file) ;; connect to socket `file', returns sd on success, nil on failure. sipc:connect(file) ;; connect to socket `file', returns sd on success, nil on failure.
sipc:send(sd value &ptional type) ;; send `value' to socket `sd' (optionally specify type (see above types), default :string) sipc:send(sd value &ptional type (keep-response t)) ;; send `value' to socket `sd' (optionally specify type (see above types), default :string). returns the response if one was sent, or t if keep-response if nil or the server did not send one.
;; :string -- value expected to be a string ;; :string -- value expected to be a string
;; :binary --value expected to be `pointer' struct ;; :binary --value expected to be `pointer' struct
;; :close -- value ignored ;; :close -- value ignored

@ -77,7 +77,7 @@
(defun send (sd value &optional (type :string) (keep-resp t)) (defun send (sd value &optional (type :string) (keep-resp t))
"send to sever on socket sd. "send to sever on socket sd.
example: (with-bound-socket (socket \"file.socket\") (hook socket ...)) example: (with-bound-socket (socket \"file.socket\") (hook socket ...))
returns (values response(t if none) nil) on success. (values nil <error>) on failure. returns (values response(t if none or keep-resp is nil) nil) on success. (values nil <error>) on failure.
error can be: error can be:
:partial - Could not write whole message :partial - Could not write whole message
:error - send() error :error - send() error
@ -121,6 +121,12 @@
rc))) rc)))
(defun respond (value &optional (type :string)) (defun respond (value &optional (type :string))
"send a response. (works same as send() but for server instead of client)
additional return values can be:
:response-invalid - this message cannot be responded to
:response-disabled - the client does not want a response
:response-multi - a response has already been sent
"
(let ((sd (symbol-value '*response-message*))) (let ((sd (symbol-value '*response-message*)))
(if sd (if sd
(let ((rc (cond (let ((rc (cond

Loading…
Cancel
Save