eventloop 0.8.1.0 → 0.8.1.1
raw patch · 5 files changed
+10/−8 lines, 5 files
Files
- eventloop.cabal +1/−1
- src/Eventloop/Module/Websocket/Canvas/Canvas.hs +1/−1
- src/Eventloop/Module/Websocket/Keyboard/Keyboard.hs +1/−1
- src/Eventloop/Module/Websocket/Mouse/Mouse.hs +1/−1
- src/Eventloop/Utility/Websockets.hs +6/−4
eventloop.cabal view
@@ -6,7 +6,7 @@ -- PVP summary: +-+------- breaking API changes -- | | +----- non-breaking API additions -- | | | +--- code changes with no API change -version: 0.8.1.0 +version: 0.8.1.1 synopsis: A different take on an IO system. Based on Amanda's IO loop, this eventloop takes a function that maps input events to output events. It can easily be extended by modules that represent IO devices or join multiple modules together. description: A different take on an IO system. Based on Amanda's IO loop, this eventloop takes a function that maps input events to output events. It can easily be extended by modules that represent IO devices or join multiple modules together. Each module exists of a initialize and teardown function that are both called once at startup and shutting down. During run-time, a module can provice a preprocessor function (which transforms input events before they get to the eventloop),
src/Eventloop/Module/Websocket/Canvas/Canvas.hs view
@@ -43,7 +43,7 @@ canvasInitializer :: Initializer canvasInitializer sharedConst sharedIO = do - (clientSocket, clientConn, serverSock) <- setupWebsocketConnection ipAddress canvasPort + (clientSocket, clientConn, serverSock) <- setupWebsocketConnection iNADDR_ANY canvasPort safePrintLn (safePrintToken sharedConst) "Canvas connection successfull!" sysRecvBuffer <- newEmptyMVar measureTextLock <- newMVar ()
src/Eventloop/Module/Websocket/Keyboard/Keyboard.hs view
@@ -45,7 +45,7 @@ keyboardInitializer :: Initializer keyboardInitializer sharedConst sharedIO = do - (clientSocket, clientConn, serverSock) <- setupWebsocketConnection ipAddress keyboardPort + (clientSocket, clientConn, serverSock) <- setupWebsocketConnection iNADDR_ANY keyboardPort safePrintLn (safePrintToken sharedConst) "Keyboard connection successfull" return (sharedConst, sharedIO, KeyboardConstants clientSocket clientConn serverSock, NoState)
src/Eventloop/Module/Websocket/Mouse/Mouse.hs view
@@ -89,7 +89,7 @@ mouseInitializer :: Initializer mouseInitializer sharedConst sharedIO = do - (clientSocket, clientConn, serverSock) <- setupWebsocketConnection ipAddress mousePort + (clientSocket, clientConn, serverSock) <- setupWebsocketConnection iNADDR_ANY mousePort safePrintLn (safePrintToken sharedConst) "Mouse connection succesfull" return (sharedConst, sharedIO, MouseConstants clientSocket clientConn serverSock, NoState)
src/Eventloop/Utility/Websockets.hs view
@@ -1,6 +1,7 @@ module Eventloop.Utility.Websockets ( module Eventloop.Utility.Websockets , Connection + , S.iNADDR_ANY ) where import qualified Network.Socket as S @@ -29,12 +30,11 @@ instance Show Connection where show _ = "Connection" -createBindListenServerSocket :: Host -> Port -> IO ServerSocket +createBindListenServerSocket :: S.HostAddress -> Port -> IO ServerSocket createBindListenServerSocket host port = do - host' <- S.inet_addr host socket <- S.socket S.AF_INET S.Stream S.defaultProtocol S.setSocketOption socket S.ReuseAddr 1 - S.bindSocket socket (S.SockAddrInet (fromIntegral port) host') + S.bindSocket socket (S.SockAddrInet (fromIntegral port) host) S.listen socket 5 return socket @@ -47,12 +47,14 @@ return (connection, clientSocket) -setupWebsocketConnection :: Host -> Port -> IO (ClientSocket, Connection, ServerSocket) +setupWebsocketConnection :: S.HostAddress -> Port -> IO (ClientSocket, Connection, ServerSocket) setupWebsocketConnection host port = S.withSocketsDo $ do serverSocket <- createBindListenServerSocket host port (clientConnection, clientSocket) <- acceptFirstConnection serverSocket return (clientSocket, clientConnection, serverSocket) + + handleCloseRequestException :: ClientSocket -> SafePrintToken -> ConnectionException -> IO (Maybe Message) handleCloseRequestException clientSocket safePrintToken (CloseRequest i reason)