~singpolyma/network-protocol-xmpp

10b2d44c2aee245e40a5808f7b14a2209e15d7b3 — John Millikin 13 years ago e40f5e2 network-protocol-xmpp_0.3.2.5
In the "echo" example, 1) don't respond to error messages and 2) allow
subscriptions.
1 files changed, 16 insertions(+), 1 deletions(-)

M examples/echo.hs
M examples/echo.hs => examples/echo.hs +16 -1
@@ 94,7 94,12 @@ runEcho hostname user password = do
			stanza <- getStanza
			liftIO $ putStr "\n" >> print stanza >> putStrLn "\n"
			case stanza of
				ReceivedMessage msg -> putStanza $ echo msg
				ReceivedMessage msg -> if messageType msg == MessageError
					then return ()
					else putStanza $ echo msg
				ReceivedPresence msg -> if presenceType msg == PresenceSubscribe
					then putStanza (subscribe msg)
					else return ()
				_ -> return ()
	
	-- If 'runClient' terminated due to an XMPP error, propagate it as an exception.


@@ 120,6 125,16 @@ echo msg = Message
	, messagePayloads = messagePayloads msg
	}

subscribe :: Presence -> Presence
subscribe p = Presence
	{ presenceType = PresenceSubscribed
	, presenceTo = presenceFrom p
	, presenceFrom = Nothing
	, presenceID = Nothing
	, presenceLang = Nothing
	, presencePayloads = []
	}

-- Send a "ping" occasionally, to prevent server timeouts from
-- closing the connection.
sendPings :: Integer -> Session -> IO ()