From dbddd0ef0bc8afb539037e937026bc9a2ab397de Mon Sep 17 00:00:00 2001 From: joe Date: Sat, 9 Nov 2013 21:38:51 -0500 Subject: Send messages to all connected clients. --- Presence/main.hs | 14 ++++++++++++++ 1 file changed, 14 insertions(+) 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 import ConfigFiles import Control.Arrow (second) import Data.Traversable (sequenceA) +import Data.List (partition) import System.INotify #ifndef NOUTMP @@ -529,6 +530,18 @@ instance JabberPeerSession PeerSession where let rsc' = maybe curtty id rsc withJust (name (msgTo msg)) $ \nto -> do + let send ((foundto,foundrsc),(ttypid,clients)) = + forM_ (Map.toList clients) $ \(pid,client) -> do + atomically $ writeTChan (clientChan client) (Chat msg) + let goodtos = filter (\((fto,_),_)->fto==nto) (Map.assocs cmap) + (good_rs,other_rs) = partition (\((_,r),_)->r==rsc') goodtos + + -- new behavior that sends to all available resources + mapM_ send good_rs + mapM_ send other_rs + -- TODO: test good_rs and other_rs for null and handle appropriately + {- + -- Old behavior that only sends to a single resource case Map.lookup (nto,rsc') cmap of Just (ttypid,clients) -> forM_ (Map.toList clients) $ \(pid,client) -> do @@ -536,6 +549,7 @@ instance JabberPeerSession PeerSession where Nothing -> -- todo: fallback return () + -} type RefCount = Int -- cgit v1.2.3