summaryrefslogtreecommitdiff
path: root/Presence
diff options
context:
space:
mode:
authorjoe <joe@jerkface.net>2013-06-19 02:45:20 -0400
committerjoe <joe@jerkface.net>2013-06-19 02:45:20 -0400
commit5ccd840ba0b48a6b9141b921e5a89059d2cad783 (patch)
treedd2e785f471be4cc9559aa759ba447e759dad585 /Presence
parent4322ba246f8276e82fb0538c40e0c41d584fa6b2 (diff)
Added listening on port 5269 for remote peers.
Diffstat (limited to 'Presence')
-rw-r--r--Presence/XMPPServer.hs23
-rw-r--r--Presence/main.hs2
2 files changed, 24 insertions, 1 deletions
diff --git a/Presence/XMPPServer.hs b/Presence/XMPPServer.hs
index 660853b6..6d7841ff 100644
--- a/Presence/XMPPServer.hs
+++ b/Presence/XMPPServer.hs
@@ -319,8 +319,9 @@ xmppParse ls = runTryParse $ do
319 319
320 320
321listenForXmppClients session_factory port st = do 321listenForXmppClients session_factory port st = do
322 -- standard port: 5222
322 let (start,dopkt) = 323 let (start,dopkt) =
323 adaptServer ( xmlLex "stream" . unpack 324 adaptServer ( xmlLex "local-client" . unpack
324 , xmppParse) 325 , xmppParse)
325 (startCon session_factory,doCon) 326 (startCon session_factory,doCon)
326 doServer (port .*. st) 327 doServer (port .*. st)
@@ -328,3 +329,23 @@ listenForXmppClients session_factory port st = do
328 start 329 start
329 330
330 331
332startPeer session_factory sock st = do
333 let h = hOccursFst st :: Handle
334 name <- fmap bshow $ getPeerName sock
335 L.putStrLn $ "REMOTE: connected " <++> name
336 let quit = L.putStrLn $ "REMOTE: disconnected " <++> name
337 return ( ConnectionFinalizer quit .*. st )
338
339doPeer st elem cont = do
340 cont ()
341
342listenForRemotePeers session_factory port st = do
343 -- standard port: 5269
344 let (start,dopkt) =
345 adaptServer ( xmlLex "remote-peer" . unpack
346 , xmppParse)
347 (startPeer session_factory,doPeer)
348 doServer (port .*. st)
349 dopkt
350 start
351
diff --git a/Presence/main.hs b/Presence/main.hs
index 44af40e3..211d7df9 100644
--- a/Presence/main.hs
+++ b/Presence/main.hs
@@ -198,12 +198,14 @@ start = do
198 dologin 198 dologin
199#endif 199#endif
200 sock <- listenForXmppClients (UnixSessions tracked) 5222 HNil 200 sock <- listenForXmppClients (UnixSessions tracked) 5222 HNil
201 sockRemotes <- listenForRemotePeers (UnixSessions tracked) 5269 HNil
201 202
202 threadDelay 1000 -- wait a moment to obtain current tty 203 threadDelay 1000 -- wait a moment to obtain current tty
203 dologin () 204 dologin ()
204 putStrLn "\nHit enter to terminate...\n" 205 putStrLn "\nHit enter to terminate...\n"
205 getLine 206 getLine
206 sClose sock 207 sClose sock
208 sClose sockRemotes
207 -- threadDelay 1000 209 -- threadDelay 1000
208 putStrLn "closed listener." 210 putStrLn "closed listener."
209 unmonitorTTY mtty 211 unmonitorTTY mtty