Created
August 29, 2014 17:27
-
-
Save deadfoxygrandpa/2a19ea0d5d55b90017e6 to your computer and use it in GitHub Desktop.
WebSockets
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
import WebSocket as WS | |
inputs = constant "" | |
socket = WS.connect "ws://127.0.0.1" inputs | |
tests = count socket | |
main = (\a b-> asText a `above` asText b) <~ socket ~ tests |
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
import qualified Network.WebSockets as WS | |
import Control.Monad (forever) | |
import Control.Concurrent (threadDelay, forkIO) | |
import qualified Data.Text as T | |
import qualified Data.ByteString.Char8 as BSC | |
application :: WS.ServerApp | |
application pendingConnection = do | |
connection <- WS.acceptRequest pendingConnection | |
forever $ do | |
WS.sendPing connection $ BSC.pack "ping" | |
WS.receive connection >>= print | |
WS.sendTextData connection (T.pack "testing...") | |
threadDelay $ 10 * 1000000 | |
main = WS.runServer "127.0.0.1" 80 application |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment