1<erl> 2out(A) -> 3 %% To use the extended version of the basic echo callback, add 4 %% 'extversion=true' in the query string. 5 CallbackMod = case queryvar(A, "extversion") of 6 {ok, "true"} -> basic_echo_callback_extended; 7 _ -> basic_echo_callback 8 end, 9 10 %% To enable keepalive timer add 'keepalive=true' in the query string. 11 KeepAlive = case queryvar(A, "keepalive") of 12 {ok, "true"} -> true; 13 _ -> false 14 end, 15 16 %% To define a keepalive timeout value, add 'timeout=Int' in the query 17 %% string. 18 Tout = case queryvar(A, "timeout") of 19 {ok, Val} -> 20 try 21 list_to_integer(Val) 22 catch 23 _:_ -> infinity 24 end; 25 _ -> 26 infinity 27 end, 28 29 %% To drop connection when a timeout occured, add 'drop=true' in the query 30 %% string. 31 Drop = case queryvar(A, "drop") of 32 {ok, "true"} -> true; 33 _ -> false 34 end, 35 36 %% To reject unmasked frames , add 'close_unmasked=true' in the query 37 %% string. 38 CloseUnmasked = case queryvar(A, "close_unmasked") of 39 {ok, "true"} -> true; 40 _ -> false 41 end, 42 43 %% NOTE: change the line below to 44 %% Opts = [{origin, any}], 45 %% if you want to accept calls from any origin. 46 Opts = [ 47 {origin, "http://" ++ (A#arg.headers)#headers.host}, 48 {keepalive, KeepAlive}, 49 {keepalive_timeout, Tout}, 50 {drop_on_timeout, Drop}, 51 {close_if_unmasked, CloseUnmasked} 52 ], 53 {websocket, CallbackMod, Opts}. 54</erl> 55