xml-push

Push XML from/to client to/from server over XMPP or HTTP

https://github.com/YoshikuniJujo/xml-push/wiki

Latest on Hackage:0.0.0.18

This package is not currently in any snapshots. If you're interested in using it, we recommend adding it to Stackage Nightly. Doing so will make builds more reliable, and allow stackage.org to host generated Haddocks.

BSD-3-Clause licensed and maintained by Yoshikuni Jujo

examples/TestSimple.hs

extensions

  • ScopedTypeVariables

module TestSimple (testSimple) where

import Control.Monad
import Control.Concurrent
import Data.Maybe
import Data.Pipe
import Data.Pipe.ByteString
import System.IO
import Text.XML.Pipe
import Network.XmlPush
import Network.XmlPush.Simple

testSimple :: Handle -> IO ()
testSimple h = do
	(sp :: SimplePusher Handle) <- generate (One h) ()
	void . forkIO . runPipe_ $ readFrom sp
		=$= convert (xmlString . (: []))
		=$= toHandle stdout
	runPipe_ $ fromHandle stdin
		=$= xmlEvent
		=$= convert fromJust
		=$= xmlNode []
		=$= writeTo sp

examples/simpleClient

import Network
import TestSimple

main :: IO ()
main = testSimple =<< connectTo "localhost" (PortNumber 54492)

examples/simpleServer

import Control.Monad
import Control.Concurrent
import Network

import TestSimple

main :: IO ()
main = forever . (void . forkIO . testSimple . fst3 =<<) . accept
	=<< listenOn (PortNumber 54492)

fst3 :: (a, b, c) -> a
fst3 (x, _, _) = x