on master help sign in
update websocket server with MVar changes
commit0bb62408d9c47c7cad7209d440358102a7dabc98 authorAgentM <agentm@themactionfaction.com> dateWed 25 Jan 2017, 11:14 (10 years ago) parenteb42ebc
2 files changed+7−5
project-m36.cabal+1−1 src/bin/ProjectM36/Server/WebSocket/websocket-server.hs+6−4
project-m36.cabal+1−1
@@ -399,7 +399,7 @@ Test-Suite test-scripts
399399
400400Executable project-m36-websocket-server
401401 Default-Language: Haskell2010
402− Build-Depends: base, aeson, path-pieces, either, conduit, http-api-data, template-haskell, persistent-template, websockets, aeson, uuid-aeson, optparse-applicative, project-m36 == 0.1, containers, bytestring, text, vector, uuid, megaparsec, haskeline, mtl, directory, base64-bytestring, random, MonadRandom, time
402+ Build-Depends: base, aeson, path-pieces, either, conduit, http-api-data, template-haskell, persistent-template, websockets, aeson, uuid-aeson, optparse-applicative, project-m36 == 0.1, containers, bytestring, text, vector, uuid, megaparsec, haskeline, mtl, directory, base64-bytestring, random, MonadRandom, time, network-transport-tcp
403403 Main-Is: ProjectM36/Server/WebSocket/websocket-server.hs
404404 Other-Modules: ProjectM36.Client.Json, ProjectM36.Server.RemoteCallTypes.Json, ProjectM36.Server.WebSocket, TutorialD.Interpreter, TutorialD.Interpreter.Base, TutorialD.Interpreter.DatabaseContextExpr, TutorialD.Interpreter.DatabaseContextIOOperator, TutorialD.Interpreter.Export.Base, TutorialD.Interpreter.Export.CSV, TutorialD.Interpreter.Import.Base, TutorialD.Interpreter.Import.BasicExamples, TutorialD.Interpreter.Import.CSV, TutorialD.Interpreter.Import.TutorialD, TutorialD.Interpreter.InformationOperator, TutorialD.Interpreter.RODatabaseContextOperator, TutorialD.Interpreter.RelationalExpr, TutorialD.Interpreter.TransactionGraphOperator, TutorialD.Interpreter.Types, TutorialD.Interpreter.TransGraphRelationalOperator
405405 GHC-Options: -Wall
src/bin/ProjectM36/Server/WebSocket/websocket-server.hs+6−4
@@ -4,16 +4,18 @@ import ProjectM36.Server.ParseArgs
44import ProjectM36.Server
55import Control.Concurrent
66import qualified Network.WebSockets as WS
7+import Network.Transport.TCP (decodeEndPointAddress)
78
89main :: IO ()
910main = do
1011 -- launch normal project-m36-server
11− portMVar <- newEmptyMVar
12+ addressMVar <- newEmptyMVar
1213 serverConfig <- parseConfig
1314 let serverHost = bindHost serverConfig
14− _ <- forkFinally (launchServer serverConfig (Just portMVar)) failureHandler
15+ _ <- forkFinally (launchServer serverConfig (Just addressMVar)) failureHandler
1516 --wait for server to be listening
16− serverPort <- takeMVar portMVar
17+ address <- takeMVar addressMVar
18+ let Just (_, serverPort, _) = decodeEndPointAddress address
1719 --this built-in server is apparently not meant for production use, but it's easier to test than starting up the wai or snap interfaces
18− WS.runServer "0.0.0.0" 8888 (websocketProxyServer serverPort serverHost)
20+ WS.runServer "0.0.0.0" 8888 (websocketProxyServer (read serverPort) serverHost)
1921