@@ -1,4 +1,4 @@
1−--module ProjectM36.Server.WebSocket where
1+module ProjectM36.Server.WebSocket where
22-- while the tutd client performs TutorialD parsing on the client, the websocket server will pass tutd to be parsed and executed on the server- otherwise I have to pull in ghcjs as a dependency to allow client-side parsing- that's not appealing because then the frontend is not language-agnostic, but this could change in the future, perhaps by sending different messages over the websocket
33-- ideally, the wire protocol should not be exposed to a straight string-based API ala SQL, so we could make perhaps a javascript DSL which compiles to the necessary JSON- anaylyze tradeoffs
44
@@ -13,29 +13,12 @@ import Data.Aeson
1313import TutorialD.Interpreter
1414import TutorialD.Interpreter.Base
1515import ProjectM36.Client
16−import ProjectM36.Server
17−import ProjectM36.Server.ParseArgs
18−import ProjectM36.Server.Config
19−import Control.Concurrent
2016import Control.Exception
2117
2218-- | Called when the project-m36-server exits.
2319failureHandler :: Either SomeException Bool -> IO ()
2420failureHandler = error "project-m36-server exited unexpectedly"
2521
26−main :: IO ()
27−main = do
28− -- launch normal project-m36-server
29− portMVar <- newEmptyMVar
30− serverConfig <- parseConfig
31− let serverHost = bindHost serverConfig
32− _ <- forkFinally (launchServer serverConfig (Just portMVar)) failureHandler
33− --wait for server to be listening
34− serverPort <- takeMVar portMVar
35− --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
36− putStrLn "listening on 8888"
37− WS.runServer "0.0.0.0" 8888 (websocketProxyServer serverPort serverHost)
38−
3922websocketProxyServer :: Port -> Hostname -> WS.ServerApp
4023websocketProxyServer port host pending = do
4124 conn <- WS.acceptRequest pending