send presence when we get XMPP presence; periodically poll presence
This commit is contained in:
parent
d6a8ac8f33
commit
0c0f2feb70
16
stuff.lisp
16
stuff.lisp
|
@ -11,6 +11,9 @@
|
||||||
((whatsapps
|
((whatsapps
|
||||||
:initform (make-hash-table :test 'equal)
|
:initform (make-hash-table :test 'equal)
|
||||||
:accessor component-whatsapps)
|
:accessor component-whatsapps)
|
||||||
|
(presence-timers
|
||||||
|
:initform (make-hash-table :test 'equal)
|
||||||
|
:accessor component-presence-timers)
|
||||||
(reconnect-timer
|
(reconnect-timer
|
||||||
:initform nil
|
:initform nil
|
||||||
:accessor component-reconnect-timer)
|
:accessor component-reconnect-timer)
|
||||||
|
@ -139,6 +142,14 @@ Commands:
|
||||||
(loop
|
(loop
|
||||||
for jid being the hash-keys in (component-whatsapps comp)
|
for jid being the hash-keys in (component-whatsapps comp)
|
||||||
using (hash-value conn)
|
using (hash-value conn)
|
||||||
|
do (when conn
|
||||||
|
(symbol-macrolet
|
||||||
|
((ticks (gethash jid (component-presence-timers comp))))
|
||||||
|
(unless ticks
|
||||||
|
(setf ticks 0))
|
||||||
|
(when (> (incf ticks) #.(/ (* 60 60) 5))
|
||||||
|
(format *debug-io* "~&periodic presence available for ~A~%" jid)
|
||||||
|
(whatscl::send-presence conn :available))))
|
||||||
append (unless conn
|
append (unless conn
|
||||||
(list jid))))
|
(list jid))))
|
||||||
(num-users (length users-to-reconnect)))
|
(num-users (length users-to-reconnect)))
|
||||||
|
@ -1219,6 +1230,11 @@ Returns three values: avatar data (as two values), and a generalized boolean spe
|
||||||
:stanza-type "presence"
|
:stanza-type "presence"
|
||||||
:id id :to from :from to
|
:id id :to from :from to
|
||||||
:e e))))
|
:e e))))
|
||||||
|
((and uid (string-equal type "available"))
|
||||||
|
(let ((conn (gethash stripped (component-whatsapps comp))))
|
||||||
|
(when conn
|
||||||
|
(format *debug-io* "~&sending available presence for ~A~%" stripped)
|
||||||
|
(whatscl::send-presence conn :available))))
|
||||||
(t nil))))))
|
(t nil))))))
|
||||||
|
|
||||||
(defun whatsxmpp-presence-probe-handler (comp &key from to id &allow-other-keys)
|
(defun whatsxmpp-presence-probe-handler (comp &key from to id &allow-other-keys)
|
||||||
|
|
Loading…
Reference in a new issue