summaryrefslogtreecommitdiff
path: root/xmppServer.hs
diff options
context:
space:
mode:
Diffstat (limited to 'xmppServer.hs')
-rw-r--r--xmppServer.hs21
1 files changed, 14 insertions, 7 deletions
diff --git a/xmppServer.hs b/xmppServer.hs
index 8656c91f..30d6b2c4 100644
--- a/xmppServer.hs
+++ b/xmppServer.hs
@@ -417,9 +417,11 @@ informClientPresence state k stanza = do
417 mb <- fmap (Map.lookup k) $ readTVar (clients state) 417 mb <- fmap (Map.lookup k) $ readTVar (clients state)
418 flip (maybe $ return ()) mb $ \cstate -> do 418 flip (maybe $ return ()) mb $ \cstate -> do
419 writeTVar (clientStatus cstate) $ Just dup 419 writeTVar (clientStatus cstate) $ Just dup
420 -- TODO: inform subscribers
420 421
421informPeerPresence state k stanza = do 422informPeerPresence state k stanza = do
422 -- Presence must indicate full JID with resource... 423 -- Presence must indicate full JID with resource...
424 putStrLn $ "xmppInformPeerPresence checking from address..."
423 flip (maybe $ return ()) (stanzaFrom stanza) $ \from -> do 425 flip (maybe $ return ()) (stanzaFrom stanza) $ \from -> do
424 let (muser,h,mresource) = splitJID from 426 let (muser,h,mresource) = splitJID from
425 flip (maybe $ return ()) mresource $ \resource -> do 427 flip (maybe $ return ()) mresource $ \resource -> do
@@ -431,15 +433,19 @@ informPeerPresence state k stanza = do
431 -- (TODO: interested/authorized clients only.) 433 -- (TODO: interested/authorized clients only.)
432 ktc <- readTVar (keyToChan state) 434 ktc <- readTVar (keyToChan state)
433 runTraversableT $ do 435 runTraversableT $ do
434 (k,client) <- liftMT $ fmap Map.toList $ readTVar (clients state) 436 (ck,client) <- liftMT $ fmap Map.toList $ readTVar (clients state)
435 con <- liftMaybe $ Map.lookup k ktc 437 con <- liftMaybe $ Map.lookup ck ktc
436 return (k,con,client) 438 return (ck,con,client)
437 forM_ clients $ \(k,con,client) -> do 439 putStrLn $ "xmppInformPeerPresence (length clients="++show (length clients)++")"
440 forM_ clients $ \(ck,con,client) -> do
438 from' <- do 441 from' <- do
439 let ClientKey laddr = k 442 let ClientKey laddr = ck
440 (_,trip) <- rewriteJIDForClient laddr from 443 (_,trip) <- rewriteJIDForClient laddr from
441 return trip 444 return (unsplitJID trip)
442 sendModifiedStanzaToClient stanza (connChan con) 445 putStrLn $ "sending to client: " ++ show (stanzaType stanza)
446 dup <- cloneStanza stanza
447 sendModifiedStanzaToClient (dup { stanzaFrom=Just from' })
448 (connChan con)
443 449
444answerProbe state k stanza chan = do 450answerProbe state k stanza chan = do
445 putStrLn $ "answerProbe! " ++ show (stanzaType stanza) 451 putStrLn $ "answerProbe! " ++ show (stanzaType stanza)
@@ -455,6 +461,7 @@ answerProbe state k stanza chan = do
455 lpres <- liftMaybe $ Map.lookup u cbu 461 lpres <- liftMaybe $ Map.lookup u cbu
456 clientState <- liftT $ Map.elems (networkClients lpres) 462 clientState <- liftT $ Map.elems (networkClients lpres)
457 stanza <- liftIOMaybe $ atomically (readTVar (clientStatus clientState)) 463 stanza <- liftIOMaybe $ atomically (readTVar (clientStatus clientState))
464 stanza <- lift $ cloneStanza stanza
458 let jid = unsplitJID (Just $ clientUser clientState 465 let jid = unsplitJID (Just $ clientUser clientState
459 , ch 466 , ch
460 ,Just $ clientResource clientState) 467 ,Just $ clientResource clientState)