Permalink
Browse files

Add a simple Haskell WebSocket server

  • Loading branch information...
1 parent 96eff60 commit a6c1e47d370c375b2cc16f40aa57467d0dc61213 Oliver Charles committed Jun 13, 2012
Showing with 18 additions and 1 deletion.
  1. +4 −0 competition/Makefile
  2. +10 −0 competition/wsdemo-snap.hs
  3. +4 −1 configure_ubuntu.sh
View
4 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
View
10 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
View
5 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

0 comments on commit a6c1e47

Please sign in to comment.