Skip to content

Commit

Permalink
adapt changes in client library
Browse files Browse the repository at this point in the history
  • Loading branch information
LoW0lf committed Jun 3, 2015
1 parent 1846dec commit eb6bf13
Showing 1 changed file with 12 additions and 6 deletions.
18 changes: 12 additions & 6 deletions src/Main.hs
Original file line number Diff line number Diff line change
Expand Up @@ -30,14 +30,17 @@ main = do
portInput <- getLine
connect sock (SockAddrInet 4343 ip) --TODO: Port Input
putStrLn "Give Client Id"
clientId <- getLine
client <- getLine

let requestHeader = Head 0 0 (stringToClientId client)

-------------------
-- Get Metadata from known broker
------------------
sendRequest sock $ encodeMdRequest (0, 0, clientId, [])
let mdReq = Metadata requestHeader [] -- request Metadata for all topics
sendRequest sock $ (pack mdReq)
mdInput <- SBL.recv sock 4096
let mdRes = decodeMdResponse mdInput
let mdRes = decodeMdResponse mdInput
print "Brokers Metadata:"
print mdRes

Expand All @@ -46,16 +49,19 @@ main = do
--------------
putStrLn "Give Topic Name"
topicName <- getLine
let t = stringToTopic topicName
putStrLn "Give Partition Number"
partition <- getLine
let p = read partition :: Int

-------------------------
-- Send / Receive Loop
-------------------------
-------------------------
forever $ do
putStrLn "Nachricht eingeben"
inputMessage <- getLine
sendRequest sock $ packPrRqMessage (C.pack $ clientId,C.pack $ topicName, (read partition ::Int), [C.pack $ inputMessage])
input <- getLine
let prReq = Produce requestHeader [ ToTopic t [ ToPart p [(stringToData input)]]]
sendRequest sock $ pack prReq

--------------------
-- Receive Response
Expand Down

0 comments on commit eb6bf13

Please sign in to comment.