Skip to content
This repository has been archived by the owner on Apr 4, 2018. It is now read-only.

Commit

Permalink
Migrate chat example to ByteString.
Browse files Browse the repository at this point in the history
  • Loading branch information
Toralf Wittner committed Jan 22, 2010
1 parent f65cca6 commit 50ce3e1
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 4 deletions.
3 changes: 2 additions & 1 deletion test/display.hs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import System.IO
import System.Exit
import System.Environment
import qualified System.ZMQ as ZMQ
import qualified Data.ByteString as SB

main :: IO ()
main = do
Expand All @@ -17,6 +18,6 @@ main = do
ZMQ.connect s addr
forever $ do
line <- ZMQ.receive s []
putStrLn line
SB.putStrLn line
hFlush stdout

10 changes: 7 additions & 3 deletions test/prompt.hs
Original file line number Diff line number Diff line change
@@ -1,8 +1,12 @@
{-# LANGUAGE OverloadedStrings #-}
import Control.Applicative
import Control.Monad
import System.IO
import System.Exit
import System.Environment
import qualified System.ZMQ as ZMQ
import qualified Data.ByteString.UTF8 as SB
import qualified Data.ByteString.Char8 as SB

main :: IO ()
main = do
Expand All @@ -11,11 +15,11 @@ main = do
hPutStrLn stderr "usage: prompt <address> <username>"
exitFailure
let addr = args !! 0
name = args !! 1
name = SB.append (SB.fromString $ args !! 1) ": "
c <- ZMQ.init 1 1 False
s <- ZMQ.socket c ZMQ.Pub
ZMQ.connect s addr
forever $ do
line <- getLine
ZMQ.send s (name ++ ": " ++ line) []
line <- SB.fromString <$> getLine
ZMQ.send s (SB.append name line) []

0 comments on commit 50ce3e1

Please sign in to comment.