diff options
Diffstat (limited to 'Presence')
-rw-r--r-- | Presence/XMPPServer.hs | 14 |
1 files changed, 13 insertions, 1 deletions
diff --git a/Presence/XMPPServer.hs b/Presence/XMPPServer.hs index 8845ea72..08e0b8c3 100644 --- a/Presence/XMPPServer.hs +++ b/Presence/XMPPServer.hs | |||
@@ -248,6 +248,18 @@ wlog s = putStrLn s >> hFlush stdout | |||
248 | wlogb :: ByteString -> IO () | 248 | wlogb :: ByteString -> IO () |
249 | wlogb s = Strict8.putStrLn s >> hFlush stdout | 249 | wlogb s = Strict8.putStrLn s >> hFlush stdout |
250 | 250 | ||
251 | flushPassThrough :: Monad m => Conduit a m b -> Conduit (Flush a) m (Flush b) | ||
252 | flushPassThrough c = getZipConduit $ ZipConduit (onlyChunks =$= mapOutput Chunk c) <* ZipConduit onlyFlushes | ||
253 | where | ||
254 | onlyChunks :: Monad m => Conduit (Flush a) m a | ||
255 | onlyFlushes :: Monad m => Conduit (Flush a) m (Flush b) | ||
256 | onlyChunks = awaitForever yieldChunk | ||
257 | onlyFlushes = awaitForever yieldFlush | ||
258 | yieldFlush Flush = yield Flush | ||
259 | yieldFlush _ = return () | ||
260 | yieldChunk (Chunk x) = yield x | ||
261 | yieldChunk _ = return () | ||
262 | |||
251 | xmlStream :: ReadCommand -> WriteCommand -> ( Source IO XML.Event | 263 | xmlStream :: ReadCommand -> WriteCommand -> ( Source IO XML.Event |
252 | , Sink (Flush XML.Event) IO () ) | 264 | , Sink (Flush XML.Event) IO () ) |
253 | xmlStream conread conwrite = (xsrc,xsnk) | 265 | xmlStream conread conwrite = (xsrc,xsnk) |
@@ -255,7 +267,7 @@ xmlStream conread conwrite = (xsrc,xsnk) | |||
255 | xsrc = src $= XML.parseBytes XML.def | 267 | xsrc = src $= XML.parseBytes XML.def |
256 | xsnk :: Sink (Flush Event) IO () | 268 | xsnk :: Sink (Flush Event) IO () |
257 | xsnk = -- XML.renderBytes XML.def =$ snk | 269 | xsnk = -- XML.renderBytes XML.def =$ snk |
258 | XML.renderBuilderFlush XML.def | 270 | flushPassThrough (XML.renderBuilder XML.def) |
259 | =$= builderToByteStringFlush | 271 | =$= builderToByteStringFlush |
260 | =$= discardFlush | 272 | =$= discardFlush |
261 | =$ snk | 273 | =$ snk |