File: test.hs

package info (click to toggle)
haskell-ami 0.1-3
  • links: PTS, VCS
  • area: main
  • in suites: jessie, jessie-kfreebsd
  • size: 92 kB
  • sloc: haskell: 260; makefile: 2
file content (30 lines) | stat: -rw-r--r-- 770 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
{-# LANGUAGE OverloadedStrings #-}
import Control.Monad.Trans
import Control.Concurrent

import Network.AMI

info = ConnectInfo {
         ciHost = "localhost",
         ciPort = 5038,
         ciUsername = "monitor",
         ciSecret = "PASSWORD" }

main = do
  forkIO test
  threadDelay 150
  test

test = withAMI_MD5 info $ do
  handleEvent "FullyBooted" onBooted
  mail <- query "MailboxCount" [("Mailbox","900")]
  liftIO $ print mail
  jabber <- query "JabberSend" [("Jabber", "asterisk"),
                           ("JID", "portnov@free-alt.ru"),
                           ("ScreenName", "asterisk"),
                           ("Message", "Jabber via AMI")]
  liftIO $ print jabber

onBooted ps = liftIO $ do
  putStrLn "Asterisk is fully booted."
  print ps