summaryrefslogtreecommitdiff
path: root/Assistant/Threads
diff options
context:
space:
mode:
authorGravatar Joey Hess <joey@kitenet.net>2012-10-24 17:23:21 -0400
committerGravatar Joey Hess <joey@kitenet.net>2012-10-24 17:23:21 -0400
commit98aaf593f3d602858a995649e7b3f578854dcf89 (patch)
tree89d0f71cc17da12573fb69956da05fef6d00b301 /Assistant/Threads
parent5cacdef3197201f80d2cf1f2121e25f6b91eb189 (diff)
flip availablility
Seems presence notifications are not sent to clients that have marked themselves unavailable. (Testing with google talk.) This is the death knell for the presence hack, because it has to stay available, and even the toggle to unavailable and back could cause it to miss a notification. Still, flipped it so it basically works, for now.
Diffstat (limited to 'Assistant/Threads')
-rw-r--r--Assistant/Threads/PushNotifier.hs11
1 files changed, 6 insertions, 5 deletions
diff --git a/Assistant/Threads/PushNotifier.hs b/Assistant/Threads/PushNotifier.hs
index 8d761dc55..39072b85e 100644
--- a/Assistant/Threads/PushNotifier.hs
+++ b/Assistant/Threads/PushNotifier.hs
@@ -43,25 +43,26 @@ pushNotifierThread st dstatus pushnotifier = NamedThread thisThread $ do
client c jid = runClient server jid (xmppUsername c) (xmppPassword c) $ do
void $ bindJID jid
- void $ putStanza $ emptyPresence PresenceUnavailable
s <- getSession
- _ <- liftIO $ forkIO $ void $ sendnotifications s
- receivenotifications
+ _ <- liftIO $ forkIO $ void $ runXMPP s $
+ receivenotifications
+ sendnotifications
where
server = Server
(JID Nothing (jidDomain jid) Nothing)
(xmppHostname c)
(PortNumber $ fromIntegral $ xmppPort c)
- sendnotifications session = runXMPP session $ forever $ do
+ sendnotifications = forever $ do
us <- liftIO $ waitPush pushnotifier
{- Toggle presence to send the notification. -}
+ putStanza $ emptyPresence PresenceUnavailable
putStanza $ (emptyPresence PresenceAvailable)
{ presenceID = Just $ encodePushNotification us }
- putStanza $ emptyPresence PresenceUnavailable
receivenotifications = forever $ do
s <- getStanza
+ liftIO $ print s
case s of
ReceivedPresence (Presence { presenceType = PresenceAvailable, presenceID = Just t }) ->
maybe noop (liftIO . pull st dstatus)