summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorjoe <joe@jerkface.net>2014-02-16 17:37:39 -0500
committerjoe <joe@jerkface.net>2014-02-16 17:37:39 -0500
commit0cb2c11613208cbeb8fb012b63b05b8ea4d6da84 (patch)
tree1cb92fe4415fd2174faa138292e1ae76a52a529e
parent585e8aca57f0fdb09dd6cf42cb67af23448cdc6a (diff)
xmppDeliverMessage
-rw-r--r--Presence/XMPPServer.hs5
-rw-r--r--xmppServer.hs9
2 files changed, 14 insertions, 0 deletions
diff --git a/Presence/XMPPServer.hs b/Presence/XMPPServer.hs
index d3df48d0..4c87ba65 100644
--- a/Presence/XMPPServer.hs
+++ b/Presence/XMPPServer.hs
@@ -7,6 +7,7 @@ module XMPPServer
7 , StanzaType(..) 7 , StanzaType(..)
8 , StanzaOrigin(..) 8 , StanzaOrigin(..)
9 , cloneStanza 9 , cloneStanza
10 , LangSpecificMessage(..)
10 ) where 11 ) where
11import Debug.Trace 12import Debug.Trace
12import Control.Monad.Trans.Resource (runResourceT) 13import Control.Monad.Trans.Resource (runResourceT)
@@ -129,6 +130,7 @@ data XMPPServerParameters =
129 , xmppRosterOthers :: ConnectionKey -> IO [Text] 130 , xmppRosterOthers :: ConnectionKey -> IO [Text]
130 , xmppLookupClientJID :: ConnectionKey -> IO Text 131 , xmppLookupClientJID :: ConnectionKey -> IO Text
131 , xmppLookupPeerName :: ConnectionKey -> IO Text 132 , xmppLookupPeerName :: ConnectionKey -> IO Text
133 , xmppDeliverMessage :: (IO ()) -> Stanza -> IO ()
132 } 134 }
133 135
134-- TODO: http://xmpp.org/rfcs/rfc6120.html#rules-remote-error 136-- TODO: http://xmpp.org/rfcs/rfc6120.html#rules-remote-error
@@ -835,6 +837,9 @@ monitor sv params xmpp = do
835 sendReply quitVar Pong reply replyto 837 sendReply quitVar Pong reply replyto
836 RequestRoster -> 838 RequestRoster ->
837 sendRoster stanza xmpp replyto 839 sendRoster stanza xmpp replyto
840 Message {} -> do
841 let fail = return () -- todo
842 xmppDeliverMessage xmpp fail stanza
838 UnrecognizedQuery query -> do 843 UnrecognizedQuery query -> do
839 let reply = iq_service_unavailable (stanzaId stanza) "localhost" query 844 let reply = iq_service_unavailable (stanzaId stanza) "localhost" query
840 sendReply quitVar Error reply replyto 845 sendReply quitVar Error reply replyto
diff --git a/xmppServer.hs b/xmppServer.hs
index 4601dbe9..ae3561db 100644
--- a/xmppServer.hs
+++ b/xmppServer.hs
@@ -10,6 +10,9 @@ import Network.Socket
10 , addrFlags 10 , addrFlags
11 , AddrInfoFlag(AI_CANONNAME) 11 , AddrInfoFlag(AI_CANONNAME)
12 ) 12 )
13import Data.Monoid ( (<>) )
14import qualified Data.Text.IO as Text
15import Control.Monad
13 16
14 17
15import XMPPServer 18import XMPPServer
@@ -27,6 +30,12 @@ main = runResourceT $ do
27 , xmppRosterOthers = \k -> return [] 30 , xmppRosterOthers = \k -> return []
28 , xmppLookupPeerName = \k -> return "localhost" 31 , xmppLookupPeerName = \k -> return "localhost"
29 , xmppLookupClientJID = \k -> return "nobody@localhost/tty666" 32 , xmppLookupClientJID = \k -> return "nobody@localhost/tty666"
33 , xmppDeliverMessage = \fail msg -> do
34 let msgs = msgLangMap (stanzaType msg)
35 body = fmap (maybe "" id . msgBody . snd) $ take 1 msgs
36 when (not $ null body) $ do
37 Text.putStrLn $ "MESSAGE " <> head body
38 return ()
30 } 39 }
31 liftIO $ do 40 liftIO $ do
32 let testaddr0 = "fd97:ca88:fa7c:b94b:c8b8:fad4:1021:a54d" 41 let testaddr0 = "fd97:ca88:fa7c:b94b:c8b8:fad4:1021:a54d"