-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathinformer.lisp
41 lines (35 loc) · 1.53 KB
/
informer.lisp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
;;;; informer.lisp --- An example program demonstrating the informer.
;;;;
;;;; Copyright (C) 2011, 2012, 2013, 2014, 2015 Jan Moringen
;;;;
;;;; Author: Jan Moringen <[email protected]>
;; mark-start::body
;; For managing the lifetime of informers (e.g. for short-lived
;; informers), the `with-participant' macro can used. It will take
;; care of disposing of the `informer' instance after it has been
;; used, also in case of non-local exist.
;; mark-start::with-participant
(rsb:with-participant (informer :informer "/example/informer"
:type 'string)
(format t "Sending first event~%")
(rsb:send informer "example payload"))
;; mark-end::with-participant
;; The following code will create an `informer' instance that
;; publishes events to the channel designated by the scope
;; "/example/informer" and is restricted to event payloads of type
;; string. The informer will use all transports which are enabled in
;; the configuration with their respective configured options.
;;
;; This will publish the string "data" to the channel in which the
;; informer participates.
;;
;; mark-start::variable
(defvar *informer* (rsb:make-participant :informer "/example/informer"
:type 'string))
(format t "Sending second event~%")
(rsb:send *informer* "example payload")
;; The informer will participate in the channel until it is garbage
;; collected or explicitly detached using the `rsb:detach' function.
(rsb:detach *informer*)
;; mark-end::variable
;; mark-end::body