summaryrefslogtreecommitdiff
path: root/Presence
diff options
context:
space:
mode:
authorjoe <joe@jerkface.net>2013-07-02 13:52:13 -0400
committerjoe <joe@jerkface.net>2013-07-02 13:52:13 -0400
commitf86afeb6a028d46a436a7eb6065c007381cce5a0 (patch)
tree5188a0891b1aeef1e4071ff49011d7250f51ee6a /Presence
parentd6d23835b19f1d804be5c5a181fd38586bb6b136 (diff)
presence probe bug fixes
Diffstat (limited to 'Presence')
-rw-r--r--Presence/XMPP.hs25
-rw-r--r--Presence/main.hs3
2 files changed, 20 insertions, 8 deletions
diff --git a/Presence/XMPP.hs b/Presence/XMPP.hs
index 99e7b3f1..c81ed8c7 100644
--- a/Presence/XMPP.hs
+++ b/Presence/XMPP.hs
@@ -543,10 +543,13 @@ handlePresenceProbe session stanza = do
543 liftIO $ L.putStrLn $ "RECEIVED PROBE "<++>bshow (peerAddress session,to) 543 liftIO $ L.putStrLn $ "RECEIVED PROBE "<++>bshow (peerAddress session,to)
544 liftIO $ do 544 liftIO $ do
545 subs <- getSubscribers (peerSessionFactory session) user 545 subs <- getSubscribers (peerSessionFactory session) user
546 liftIO $ L.putStrLn $ "subscribers for "<++>bshow user<++>": " <++>bshow subs
546 forM_ subs $ \jidstr -> do 547 forM_ subs $ \jidstr -> do
547 handle (\(SomeException _) -> return ()) $ do 548 handle (\(SomeException _) -> return ()) $ do
549 L.putStrLn $ "parsing " <++>jidstr
548 sub <- parseHostNameJID jidstr 550 sub <- parseHostNameJID jidstr
549 when (peer sub == peer jid) $ do 551 putStrLn $ "comparing " ++show (peer sub , peerAddress session)
552 when (peer sub == peerAddress session) $ do
550 ps <- userStatus session user 553 ps <- userStatus session user
551 mapM_ (announcePresence session) ps 554 mapM_ (announcePresence session) ps
552 return () 555 return ()
@@ -692,6 +695,7 @@ toPeer sock cache chan = do
692 send r 695 send r
693 forM_ (Map.assocs . probes $ cache) $ \(to,froms) -> do 696 forM_ (Map.assocs . probes $ cache) $ \(to,froms) -> do
694 forM_ (Set.toList froms) $ \from -> do 697 forM_ (Set.toList froms) $ \from -> do
698 liftIO $ L.putStrLn "sending cached probe..."
695 r <- liftIO $ presenceProbe sock from to 699 r <- liftIO $ presenceProbe sock from to
696 send r 700 send r
697 fix $ \loop -> do 701 fix $ \loop -> do
@@ -701,22 +705,27 @@ toPeer sock cache chan = do
701 r <- lift $ xmlifyPresenceForPeer sock p 705 r <- lift $ xmlifyPresenceForPeer sock p
702 send r 706 send r
703 PresenceProbe from to -> do 707 PresenceProbe from to -> do
708 liftIO $ L.putStrLn "sending live probe..."
704 r <- liftIO $ presenceProbe sock from to 709 r <- liftIO $ presenceProbe sock from to
705 send r 710 send r
706 loop 711 loop
707 send goodbyePeer 712 send goodbyePeer
708 713
709handleOutgoingToPeer sock cache chan snk = do 714handleOutgoingToPeer sock cache chan snk = do
715 p <- getPeerName sock
716 L.putStrLn $ "(>P) connected " <++> showPeer (RemotePeer p)
717 finally (
710#ifdef RENDERFLUSH 718#ifdef RENDERFLUSH
711 toPeer sock cache chan 719 toPeer sock cache chan
712 $$ flushList 720 $$ flushList
713 =$= renderBuilderFlush def 721 =$= renderBuilderFlush def
714 =$= builderToByteStringFlush 722 =$= builderToByteStringFlush
715 =$= discardFlush 723 =$= discardFlush
716 =$ snk 724 =$ snk
717#else 725#else
718 toPeer sock cache chan $$ renderChunks =$ snk 726 toPeer sock cache chan $$ renderChunks =$ snk
719#endif 727#endif
728 ) $ L.putStrLn $ "(>P) disconnected " <++> showPeer (RemotePeer p)
720 729
721connect' :: SockAddr -> Int -> IO (Maybe Socket) 730connect' :: SockAddr -> Int -> IO (Maybe Socket)
722connect' addr port = do 731connect' addr port = do
diff --git a/Presence/main.hs b/Presence/main.hs
index 7981f00b..7a0ee2b4 100644
--- a/Presence/main.hs
+++ b/Presence/main.hs
@@ -247,6 +247,7 @@ newPresenceState hostname = atomically $ do
247 return $ PresenceState hostname tty us subs locals_greedy remotes server_connections 247 return $ PresenceState hostname tty us subs locals_greedy remotes server_connections
248 248
249sendProbes state jid = do 249sendProbes state jid = do
250 L.putStrLn $ "sending probes for " <++> bshow jid
250 withJust (name jid) $ \user -> do 251 withJust (name jid) $ \user -> do
251 let parseHostNameJID' str = do 252 let parseHostNameJID' str = do
252 handle (\(SomeException _) -> return Nothing) 253 handle (\(SomeException _) -> return Nothing)
@@ -254,12 +255,14 @@ sendProbes state jid = do
254 buddies <- do 255 buddies <- do
255 buddies <- ConfigFiles.getBuddies user 256 buddies <- ConfigFiles.getBuddies user
256 fmap catMaybes (mapM parseHostNameJID' buddies) 257 fmap catMaybes (mapM parseHostNameJID' buddies)
258 L.putStrLn $ "buddies for " <++> bshow jid <++> " = " <++> bshow buddies
257 remotes <- readTVarIO (remoteUsers state) 259 remotes <- readTVarIO (remoteUsers state)
258 forM_ buddies $ \buddy -> do 260 forM_ buddies $ \buddy -> do
259 let mjids = fmap snd $ Map.lookup (peer buddy) remotes 261 let mjids = fmap snd $ Map.lookup (peer buddy) remotes
260 jids <- maybe (return Set.empty) readTVarIO mjids 262 jids <- maybe (return Set.empty) readTVarIO mjids
261 let noinfo = Set.notMember buddy jids 263 let noinfo = Set.notMember buddy jids
262 when noinfo $ do 264 when noinfo $ do
265 L.putStrLn $ "sendMessage " <++> bshow (PresenceProbe jid buddy)
263 sendMessage (outGoingConnections state) (PresenceProbe jid buddy) (peer buddy) 266 sendMessage (outGoingConnections state) (PresenceProbe jid buddy) (peer buddy)
264 return () 267 return ()
265 268