From a6c1e47d370c375b2cc16f40aa57467d0dc61213 Mon Sep 17 00:00:00 2001 From: Oliver Charles Date: Wed, 13 Jun 2012 22:41:59 +0100 Subject: [PATCH] Add a simple Haskell WebSocket server --- competition/Makefile | 4 ++++ competition/wsdemo-snap.hs | 10 ++++++++++ configure_ubuntu.sh | 5 ++++- 3 files changed, 18 insertions(+), 1 deletion(-) create mode 100644 competition/wsdemo-snap.hs diff --git a/competition/Makefile b/competition/Makefile index 71f489c..c29a1a0 100644 --- a/competition/Makefile +++ b/competition/Makefile @@ -1,5 +1,9 @@ build: javac -cp webbit-0.4.7-full.jar EchoWsServer.java + ghc --make -O2 -threaded wsdemo-snap.hs clean: rm *.class + rm *snap.hi + rm *snap.o + rm wsdemo-snap diff --git a/competition/wsdemo-snap.hs b/competition/wsdemo-snap.hs new file mode 100644 index 0000000..758f0c4 --- /dev/null +++ b/competition/wsdemo-snap.hs @@ -0,0 +1,10 @@ +import Control.Monad +import Snap.Http.Server +import Network.WebSockets +import Network.WebSockets.Snap + +echo :: Request -> WebSockets Hybi00 () +echo req = acceptRequest req >> forever (receive >>= send) + +main :: IO () +main = quickHttpServe $ runWebSocketsSnap echo diff --git a/configure_ubuntu.sh b/configure_ubuntu.sh index a1b4213..53c282f 100755 --- a/configure_ubuntu.sh +++ b/configure_ubuntu.sh @@ -1,4 +1,4 @@ -sudo apt-get install -y emacs python-dev python-setuptools build-essential erlang-nox libevent-dev git golang mercurial default-jdk ruby rubygems +sudo apt-get install -y emacs python-dev python-setuptools build-essential erlang-nox libevent-dev git golang mercurial default-jdk ruby rubygems haskell-platform sudo easy_install ws4py gevent git clone git://github.com/ericmoritz/wsdemo.git wsdemo @@ -17,3 +17,6 @@ popd npm install websocket sudo go get code.google.com/p/go.net/websocket sudo gem install em-websocket + +sudo cabal update +sudo cabal install snap-server snap-core websockets websockets-snap