diff options
author | Loïc Hoguin <[email protected]> | 2011-08-10 20:28:30 +0200 |
---|---|---|
committer | Loïc Hoguin <[email protected]> | 2011-08-10 20:28:30 +0200 |
commit | 43d14b52cd07dfd1121bbe6727a96dfd32304e47 (patch) | |
tree | 5b8d451d0decec8e75cf70c24e5c3fb54f51a65c /src/cowboy_http_websocket.erl | |
parent | 56369d5c1a0a3141e9d136b2f8010ff0e96bb26c (diff) | |
download | cowboy-43d14b52cd07dfd1121bbe6727a96dfd32304e47.tar.gz cowboy-43d14b52cd07dfd1121bbe6727a96dfd32304e47.tar.bz2 cowboy-43d14b52cd07dfd1121bbe6727a96dfd32304e47.zip |
Give the ListenerPid to the protocol on startup
Also sends a message 'shoot' that can be received by the protocol
to make sure Cowboy has had enough time to fully initialize the
socket. This message should be received before any socket-related
operations are performed.
WebSocket request connections are now moved from the pool 'default'
to the pool 'websocket', meaning we can have a lot of running
WebSockets despite having a low 'max_connections' setting.
Diffstat (limited to 'src/cowboy_http_websocket.erl')
-rw-r--r-- | src/cowboy_http_websocket.erl | 7 |
1 files changed, 4 insertions, 3 deletions
diff --git a/src/cowboy_http_websocket.erl b/src/cowboy_http_websocket.erl index 66187f0..63113d6 100644 --- a/src/cowboy_http_websocket.erl +++ b/src/cowboy_http_websocket.erl @@ -23,7 +23,7 @@ %% </ul> -module(cowboy_http_websocket). --export([upgrade/3]). %% API. +-export([upgrade/4]). %% API. -export([handler_loop/4]). %% Internal. -include("include/http.hrl"). @@ -45,8 +45,9 @@ %% You do not need to call this function manually. To upgrade to the WebSocket %% protocol, you simply need to return <em>{upgrade, protocol, {@module}}</em> %% in your <em>cowboy_http_handler:init/3</em> handler function. --spec upgrade(module(), any(), #http_req{}) -> ok. -upgrade(Handler, Opts, Req) -> +-spec upgrade(pid(), module(), any(), #http_req{}) -> ok. +upgrade(ListenerPid, Handler, Opts, Req) -> + cowboy_listener:move_connection(ListenerPid, websocket, self()), EOP = binary:compile_pattern(<< 255 >>), case catch websocket_upgrade(#state{handler=Handler, opts=Opts, eop=EOP}, Req) of {ok, State, Req2} -> handler_init(State, Req2); |