Last active
November 16, 2015 18:35
-
-
Save skatenerd/36673122e4fe3ff523a7 to your computer and use it in GitHub Desktop.
basic server, sends echo messages back to clients. works in Chrome and FF, but not Chromium
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{-# LANGUAGE ScopedTypeVariables #-} | |
{-# LANGUAGE OverloadedStrings #-} | |
module Main where | |
import Data.Text (Text) | |
import qualified Data.Text.IO as T | |
import qualified Network.WebSockets as WS | |
type Client = (Text, WS.Connection) | |
main :: IO () | |
main = WS.runServer "0.0.0.0" 9160 myApp | |
myApp :: WS.ServerApp | |
myApp pending = do | |
conn <- WS.acceptRequest pending | |
msg :: Text <- WS.receiveData conn | |
T.putStrLn "GOT A MESG" | |
WS.sendTextData conn msg |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment