summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorjoe <joe@jerkface.net>2013-11-09 21:38:51 -0500
committerjoe <joe@jerkface.net>2013-11-11 16:01:17 -0500
commitdbddd0ef0bc8afb539037e937026bc9a2ab397de (patch)
tree352a4a6ad0676aa8fc4002a4493603162d148ec6
parent75be0db86119a91a1362a9680bb79d8a44adb18c (diff)
Send messages to all connected clients.
-rw-r--r--Presence/main.hs14
1 files changed, 14 insertions, 0 deletions
diff --git a/Presence/main.hs b/Presence/main.hs
index 3215913b..45b8729a 100644
--- a/Presence/main.hs
+++ b/Presence/main.hs
@@ -16,6 +16,7 @@ import Data.Char
16import ConfigFiles 16import ConfigFiles
17import Control.Arrow (second) 17import Control.Arrow (second)
18import Data.Traversable (sequenceA) 18import Data.Traversable (sequenceA)
19import Data.List (partition)
19 20
20import System.INotify 21import System.INotify
21#ifndef NOUTMP 22#ifndef NOUTMP
@@ -529,6 +530,18 @@ instance JabberPeerSession PeerSession where
529 530
530 let rsc' = maybe curtty id rsc 531 let rsc' = maybe curtty id rsc
531 withJust (name (msgTo msg)) $ \nto -> do 532 withJust (name (msgTo msg)) $ \nto -> do
533 let send ((foundto,foundrsc),(ttypid,clients)) =
534 forM_ (Map.toList clients) $ \(pid,client) -> do
535 atomically $ writeTChan (clientChan client) (Chat msg)
536 let goodtos = filter (\((fto,_),_)->fto==nto) (Map.assocs cmap)
537 (good_rs,other_rs) = partition (\((_,r),_)->r==rsc') goodtos
538
539 -- new behavior that sends to all available resources
540 mapM_ send good_rs
541 mapM_ send other_rs
542 -- TODO: test good_rs and other_rs for null and handle appropriately
543 {-
544 -- Old behavior that only sends to a single resource
532 case Map.lookup (nto,rsc') cmap of 545 case Map.lookup (nto,rsc') cmap of
533 Just (ttypid,clients) -> 546 Just (ttypid,clients) ->
534 forM_ (Map.toList clients) $ \(pid,client) -> do 547 forM_ (Map.toList clients) $ \(pid,client) -> do
@@ -536,6 +549,7 @@ instance JabberPeerSession PeerSession where
536 Nothing -> 549 Nothing ->
537 -- todo: fallback 550 -- todo: fallback
538 return () 551 return ()
552 -}
539 553
540 554
541type RefCount = Int 555type RefCount = Int