summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Presence/XMPP.hs29
1 files changed, 24 insertions, 5 deletions
diff --git a/Presence/XMPP.hs b/Presence/XMPP.hs
index 3c68da4a..eb1774d1 100644
--- a/Presence/XMPP.hs
+++ b/Presence/XMPP.hs
@@ -645,6 +645,25 @@ goodbyePeer =
645 , EventEndDocument 645 , EventEndDocument
646 ] 646 ]
647 647
648presenceProbe sock fromjid tojid = do
649 addr <- getSocketName sock
650 let jidstr jid = toStrict . L.decodeUtf8
651 $ name jid <$++> "@"
652 <?++> showPeer (RemotePeer addr)
653 <++?> "/" <++$> resource jid
654 from = jidstr fromjid
655 to = toStrict . L.decodeUtf8
656 $ name tojid <$++> "@"
657 <?++> showPeer (peer tojid)
658 return
659 [ EventBeginElement "{jabber:server}presence"
660 [("from",[ContentText from])
661 ,("to",[ContentText to])
662 ,("type",[ContentText "probe"])
663 ]
664 , EventEndElement "{jabber:server}presence"
665 ]
666
648toPeer sock cache chan = do 667toPeer sock cache chan = do
649 let -- log = liftIO . L.putStrLn . ("(>P) " <++>) 668 let -- log = liftIO . L.putStrLn . ("(>P) " <++>)
650 send xs = yield xs >> prettyPrint ">P: " xs 669 send xs = yield xs >> prettyPrint ">P: " xs
@@ -653,9 +672,9 @@ toPeer sock cache chan = do
653 r <- lift $ xmlifyPresenceForPeer sock (Presence jid st) 672 r <- lift $ xmlifyPresenceForPeer sock (Presence jid st)
654 send r 673 send r
655 forM_ (Map.assocs . probes $ cache) $ \(to,froms) -> do 674 forM_ (Map.assocs . probes $ cache) $ \(to,froms) -> do
656 forM_ (Set.toList froms) $ \from -> 675 forM_ (Set.toList froms) $ \from -> do
657 -- TODO: send probe 676 r <- liftIO $ presenceProbe sock from to
658 return () 677 send r
659 fix $ \loop -> do 678 fix $ \loop -> do
660 event <- lift . atomically $ readTChan chan 679 event <- lift . atomically $ readTChan chan
661 case event of 680 case event of
@@ -663,8 +682,8 @@ toPeer sock cache chan = do
663 r <- lift $ xmlifyPresenceForPeer sock p 682 r <- lift $ xmlifyPresenceForPeer sock p
664 send r 683 send r
665 PresenceProbe from to -> do 684 PresenceProbe from to -> do
666 -- TODO: send probe 685 r <- liftIO $ presenceProbe sock from to
667 liftIO $ putStrLn ("Connection ready, PresenceProbe " ++ show (from,to) ++ " (NOT IMPLEMENTED)") 686 send r
668 loop 687 loop
669 send goodbyePeer 688 send goodbyePeer
670 689