Browse Source

Add a Transport:messages/0 function to obtain the atoms sent in active mode.

That way we can support active mode without having to hardcode the atoms
for each transports available.
Loïc Hoguin 14 years ago
parent
commit
bc99200bae
2 changed files with 11 additions and 3 deletions
  1. 4 1
      src/cowboy_ssl_transport.erl
  2. 7 2
      src/cowboy_tcp_transport.erl

+ 4 - 1
src/cowboy_ssl_transport.erl

@@ -13,7 +13,7 @@
 %% OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
 
 -module(cowboy_ssl_transport).
--export([name/0, listen/1, accept/1, recv/3, send/2, setopts/2,
+-export([name/0, messages/0, listen/1, accept/1, recv/3, send/2, setopts/2,
 	controlling_process/2, peername/1, close/1]). %% API.
 
 -include("include/types.hrl").
@@ -23,6 +23,9 @@
 -spec name() -> ssl.
 name() -> ssl.
 
+-spec messages() -> {ssl, ssl_closed, ssl_error}.
+messages() -> {ssl, ssl_closed, ssl_error}.
+
 -spec listen([{port, Port::port_number()} | {certfile, CertPath::string()}
 	| {keyfile, KeyPath::string()} | {password, Password::string()}])
 	-> {ok, LSocket::socket()} | {error, Reason::posix()}.

+ 7 - 2
src/cowboy_tcp_transport.erl

@@ -13,14 +13,19 @@
 %% OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
 
 -module(cowboy_tcp_transport).
--export([name/0, listen/1, accept/1, recv/3, send/2, setopts/2,
-	controlling_process/2, peername/1, close/1]).
+-export([name/0, messages/0, listen/1, accept/1, recv/3, send/2, setopts/2,
+	controlling_process/2, peername/1, close/1]). %% API.
 
 -include("include/types.hrl").
 
+%% API.
+
 -spec name() -> tcp.
 name() -> tcp.
 
+-spec messages() -> {tcp, tcp_closed, tcp_error}.
+messages() -> {tcp, tcp_closed, tcp_error}.
+
 -spec listen([{port, Port::port_number()}])
 	-> {ok, LSocket::socket()} | {error, Reason::posix()}.
 listen(Opts) ->