-module(basic_websocket).
-export([start/1, stop/0, loop/1]).
start(Options) ->
Loop = fun (WebSocket) ->
?MODULE:loop(WebSocket)
end,
mochiweb_websocket:start([{name, ?MODULE}, {loop, Loop} |
Options]).
stop() ->
mochiweb_websocket:stop(?MODULE).
loop(WebSocket) ->
%% Get the data sent from the client
Data = WebSocket:get_data(),
%% This is a little echo service. The "client-connected" is just
our implementation
%% for this example. See priv/www/index.html
case Data of
"client-connected" ->
WebSocket:send("You are connected!");
%% Other messages go here
Other ->
Msg = "You Said: " ++ Other,
WebSocket:send(Msg)
end.
You can find the source here: http://github.com/davebryson/erlang_websocket
This is just a quick bit of code, but it seems to work fine for
playing around.
Dave
________________________________________________________________
erlang-questions mailing list. See http://www.erlang.org/faq.html
erlang-questions (at) erlang.org
Now all we need is a javascript IRC client that talks web-sockets
and a server that understands the IRC protocol, and a backend based on a DHT
(like riak) and we have a high scalable robust p2p architecture for
chat/whatever !!!
I can contribute a IRC server that is pretty basic (it's almost done)
Just need riak integration and a javascript client.
/Joe