Skip to content

Instantly share code, notes, and snippets.

@rnons
Created March 5, 2014 06:46
Show Gist options
  • Save rnons/9362358 to your computer and use it in GitHub Desktop.
Save rnons/9362358 to your computer and use it in GitHub Desktop.
{-# 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 "username@gmail.com" 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