From 98aaf593f3d602858a995649e7b3f578854dcf89 Mon Sep 17 00:00:00 2001 From: Joey Hess Date: Wed, 24 Oct 2012 17:23:21 -0400 Subject: 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. --- Assistant/Threads/PushNotifier.hs | 11 ++++++----- 1 file 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) -- cgit v1.2.3