From 640e69ef77aea530af800741e453b05e2802d188 Mon Sep 17 00:00:00 2001 From: AndrewRademacher Date: Sat, 27 Feb 2016 20:23:26 -0600 Subject: Framed UDP function. --- src/Graylog/UDP.hs | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) (limited to 'src/Graylog') diff --git a/src/Graylog/UDP.hs b/src/Graylog/UDP.hs index dc172b9..656cbc8 100644 --- a/src/Graylog/UDP.hs +++ b/src/Graylog/UDP.hs @@ -6,8 +6,9 @@ module Graylog.UDP import Data.Aeson import qualified Data.ByteString.Lazy as LBS +import Data.Word import Network.Socket.ByteString.Lazy -import System.Random.MWC +import System.Random import Graylog.Gelf as Export import Graylog.Types as Export @@ -16,7 +17,15 @@ sendLog :: Graylog -> GELF -> IO () sendLog glog msg = mapM_ (send $ _graylogSocket glog) cks where raw = encode msg - cks = chunky raw + cks = chunky glog raw -chunky :: LBS.ByteString -> [LBS.ByteString] -chunky = undefined +chunky :: Graylog -> LBS.ByteString -> IO [LBS.ByteString] +chunky glog raw = do + groupId <- randomIO + splitAt gsize + where + magic = undefined + seq = undefined + total = undefined + hlen = 12 + gsize = (fromIntegral (_graylogChunkSize glog)) - hlen -- cgit v1.2.3