Pup-Events-Server 1.1.2 → 1.1.5
raw patch · 2 files changed
+8/−6 lines, 2 filesPVP ok
version bump matches the API change (PVP)
API changes (from Hackage documentation)
Files
- Pup-Events-Server.cabal +1/−1
- PupEventsServer.hs +7/−5
Pup-Events-Server.cabal view
@@ -1,5 +1,5 @@ name: Pup-Events-Server-version: 1.1.2+version: 1.1.5 synopsis: A networked event handling framework for hooking into other programs. description: Pup-Events is a networking enabled event handling
PupEventsServer.hs view
@@ -10,6 +10,7 @@ import Control.Concurrent.STM.TChan (tryReadTChan) import Control.Concurrent import Control.Monad+import Control.Exception.Base (finally) import qualified Control.Exception as C import Text.Parsec import Network.Socket@@ -40,7 +41,7 @@ -- listen with maximum 5 queued requests listen sock 5 -- accept forever- forever $ acceptCon sock priorities lookupPriority lookupUnHandler lookupHandler parsers dcEvent+ finally (forever $ acceptCon sock priorities lookupPriority lookupUnHandler lookupHandler parsers dcEvent) ({-hPutStr stderr "Shutting down server..." >> -}sClose sock) -- |Checks the given PQueue for an event to handle and calls the handler -- for it, then sends the event returned by the handler to the client.@@ -61,7 +62,8 @@ hFlush handle handleEvents handle pqueue lookupUnHandler lookupHandler ) (\e -> do let err = show (e :: C.IOException)- hPutStr stderr ("Client disconnected")+ {-hPutStr stderr ("Client disconnected"-}+ return () ) @@ -78,9 +80,9 @@ -> Maybe t -- ^Optional. The event to put on the pqueue when a client disconnects -> IO ThreadId acceptCon sock priorities lookupPriority lookupUnHandler lookupHandler parsers dcEvent =- do putStrLn "Accepting Connections"+ do {-hPutStr stderr "Accepting Connections\n"-} (connsock, clientaddr) <- accept sock- putStrLn $ "Connection received from: " ++ show clientaddr+ --hPutStr stderr $ "Connection received from: " ++ show clientaddr ++ "\n" connHandle <- socketToHandle connsock ReadWriteMode hSetBuffering connHandle NoBuffering hSetBinaryMode connHandle True@@ -109,7 +111,7 @@ where toDispatch str = case parse parseMsg "" str of- Left e -> putStrLn $ "ParseError: " ++ show e ++ "\nString: " ++ show str+ Left e -> hPutStr stderr $ "ParseError: " ++ show e ++ "\nString: " ++ show str ++ "\n" Right a -> atomically $ writeThing pqueue (lookupPriority a) a parseMsg = choice parsers nullLines "" = []