Created
March 5, 2014 06:46
-
-
Save rnons/9362358 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{-# LANGUAGE OverloadedStrings #-} | |
module Main where | |
import Control.Monad | |
import qualified Data.ByteString.Char8 as C | |
import Data.Default | |
import Network.TLS | |
import Network.TLS.Extra (ciphersuite_medium) | |
import Network.Xmpp | |
import System.Log.Logger | |
main :: IO () | |
main = do | |
updateGlobalLogger "Pontarius.Xmpp" $ setLevel DEBUG | |
result <- session | |
"google.com" | |
(Just (\_ -> ( [plain "[email protected]" Nothing "password"]) | |
, Nothing)) | |
def { sessionStreamConfiguration = def | |
{ tlsParams = (defaultParamsClient "" C.empty) | |
{ clientSupported = def | |
{ supportedVersions = [TLS10, TLS11, TLS12] | |
, supportedCiphers = ciphersuite_medium | |
} } } } | |
sess <- case result of | |
Right s -> return s | |
Left e -> error $ "XmppFailure: " ++ (show e) | |
sendPresence def sess | |
forever $ do | |
msg <- getMessage sess | |
case answerMessage msg (messagePayload msg) of | |
Just answer -> sendMessage answer sess >> return () | |
Nothing -> putStrLn "Received message with no sender." |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment