aboutsummaryrefslogblamecommitdiffstats
path: root/test/remove_conn_and_wait_protocol.erl
blob: 59cedfc0c08b1ccbded70837d910c368398e99ef (plain) (tree)
1
2
3
4
5
6
7
8
9
10
                                       
                           
 
                        
                  
 

                                                                     

                  
                                  
                                       

                           
                                                     


                          
                                        
-module(remove_conn_and_wait_protocol).
-behaviour(ranch_protocol).

-export([start_link/4]).
-export([init/3]).

start_link(Ref, _, _, [{remove, MaybeRemove, Timeout}]) ->
	Pid = spawn_link(?MODULE, init, [Ref, MaybeRemove, Timeout]),
	{ok, Pid}.

init(Ref, MaybeRemove, Timeout) ->
	{ok, _} = ranch:handshake(Ref),
	case MaybeRemove of
		true ->
			ranch:remove_connection(Ref);
		false ->
			ok
	end,
	receive after Timeout -> ok end.