@@ -7,7 +7,7 @@ import Streamly.Network.Socket
77import Streamly.Internal.Network.Socket (handleWithM)
88import Network.Socket as Socket
99import Network.Socket.ByteString as Socket
10−import Streamly.Internal.Data.Parser.ParserD as PD
10+import Streamly.Internal.Data.Parser as P
1111import Codec.Winery
1212import Codec.Winery.Internal (varInt, decodeVarInt, getBytes)
1313import Codec.Winery.Class (mkExtractor)
@@ -37,7 +37,7 @@ import Foreign.ForeignPtr (plusForeignPtr)
3737import Foreign.ForeignPtr.Unsafe (unsafeForeignPtrToPtr)
3838import GHC.Ptr (plusPtr)
3939
40−import Debug.Trace
40+--import Debug.Trace
4141
4242data ClientHelloMessage = ClientHelloMessage Int Int
4343 deriving Generic
@@ -105,13 +105,13 @@ localHostAddr = (127,0,0,1)
105105messageBoundaryP :: Parser IO Word8 BS.ByteString
106106messageBoundaryP = do
107107 let x = FL.toList
108− w4x8 <- PD.take 4 x
109− traceShowM ("w4x8"::String, w4x8)
108+ w4x8 <- P.take 4 x
109+ --traceShowM ("w4x8"::String, w4x8)
110110 let c = fromIntegral (BO.word32 (BS.pack w4x8))
111− traceShowM ("c"::String, c)
112− vals <- PD.take c x
111+ --traceShowM ("c"::String, c)
112+ vals <- P.take c x
113113 let bytes = BS.pack vals
114− traceShowM ("parsedBytes"::String, c, BS.length bytes, bytes)
114+ --traceShowM ("parsedBytes"::String, c, BS.length bytes, bytes)
115115 pure bytes
116116
117117type NewConnectionHandler msg = IO (Maybe msg)
@@ -186,22 +186,20 @@ drainSocketMessages sock msgHandler = do
186186 print err
187187 Right val ->
188188 msgHandler val --add response function
189− S.drain $ serially $ S.parseManyD messageBoundaryP sockStream & S.mapM handler
189+ S.drain $ serially $ S.parseMany messageBoundaryP sockStream & S.mapM handler
190190
191191--send length-tagged bytestring, perhaps should be in network byte order?
192192sendMessage :: Serialise a => Message a -> Socket -> IO ()
193193sendMessage msg socket' = do
194− let -- byteArray = toArraySlow fullbytes
195− --dbgByteString = BS.pack (SA.toList byteArray)
194+ let
196195 msgbytes = serialise msg
197196 fullbytes = lenbytes <> msgbytes
198197 len = BS.length msgbytes
199198 lenbytes = BO.bytestring32 (fromIntegral len)
200− --when (dbgByteString /= msgbytes) (error "mismatch!")
201199
202200 byteCount <- Socket.send socket' fullbytes
203201 when (byteCount /= BS.length fullbytes) (error "bytes sent mismatch")
204− traceShowM ("sent bytes:" :: String, byteCount, fullbytes)
202+ --traceShowM ("sent bytes:" :: String, byteCount, fullbytes)
205203
206204
207205
@@ -219,6 +217,6 @@ toArrayS (BSI.PS fp off len) = SA.Array nfp endPtr
219217 endPtr = unsafeForeignPtrToPtr nfp `plusPtr` len `plusPtr` 1 -- ? why +1?
220218
221219toArraySlow :: BS.ByteString -> SA.Array Word8
222−toArraySlow bs = traceShow ("arr" :: String, SA.length arr) arr
220+toArraySlow bs = arr
223221 where
224222 arr = SA.fromList (BS.unpack bs)