timer:seconds
This commit is contained in:
parent
048ad27b65
commit
22170b6c6d
|
@ -42,7 +42,7 @@
|
||||||
%%------------------------------------------------------------------------------
|
%%------------------------------------------------------------------------------
|
||||||
new({Transport, Socket}, TimeoutSec, TimeoutMsg) when TimeoutSec > 0 ->
|
new({Transport, Socket}, TimeoutSec, TimeoutMsg) when TimeoutSec > 0 ->
|
||||||
{ok, [{recv_oct, RecvOct}]} = Transport:getstat(Socket, [recv_oct]),
|
{ok, [{recv_oct, RecvOct}]} = Transport:getstat(Socket, [recv_oct]),
|
||||||
Ref = erlang:send_after(TimeoutSec*1000, self(), TimeoutMsg),
|
Ref = erlang:send_after(timer:seconds(TimeoutSec), self(), TimeoutMsg),
|
||||||
#keepalive {transport = Transport,
|
#keepalive {transport = Transport,
|
||||||
socket = Socket,
|
socket = Socket,
|
||||||
recv_oct = RecvOct,
|
recv_oct = RecvOct,
|
||||||
|
@ -67,7 +67,7 @@ resume(KeepAlive = #keepalive {transport = Transport,
|
||||||
true ->
|
true ->
|
||||||
%need?
|
%need?
|
||||||
cancel(Ref),
|
cancel(Ref),
|
||||||
NewRef = erlang:send_after(TimeoutSec*1000, self(), TimeoutMsg),
|
NewRef = erlang:send_after(timer:seconds(TimeoutSec), self(), TimeoutMsg),
|
||||||
{resumed, KeepAlive#keepalive{recv_oct = NewRecvOct, timer_ref = NewRef}}
|
{resumed, KeepAlive#keepalive{recv_oct = NewRecvOct, timer_ref = NewRef}}
|
||||||
end.
|
end.
|
||||||
|
|
||||||
|
|
|
@ -664,8 +664,8 @@ next_packet_id(Session = #session{packet_id = 16#ffff}) ->
|
||||||
next_packet_id(Session = #session{packet_id = Id}) ->
|
next_packet_id(Session = #session{packet_id = Id}) ->
|
||||||
Session#session{packet_id = Id + 1}.
|
Session#session{packet_id = Id + 1}.
|
||||||
|
|
||||||
timer(Timeout, TimeoutMsg) ->
|
timer(TimeoutSec, TimeoutMsg) ->
|
||||||
erlang:send_after(Timeout * 1000, self(), TimeoutMsg).
|
erlang:send_after(timer:seconds(TimeoutSec), self(), TimeoutMsg).
|
||||||
|
|
||||||
cancel_timer(undefined) ->
|
cancel_timer(undefined) ->
|
||||||
undefined;
|
undefined;
|
||||||
|
@ -679,7 +679,7 @@ start_collector(Session = #session{collect_interval = 0}) ->
|
||||||
Session;
|
Session;
|
||||||
|
|
||||||
start_collector(Session = #session{collect_interval = Interval}) ->
|
start_collector(Session = #session{collect_interval = Interval}) ->
|
||||||
TRef = erlang:send_after(Interval * 1000, self(), collect_info),
|
TRef = erlang:send_after(timer:seconds(Interval), self(), collect_info),
|
||||||
Session#session{collect_timer = TRef}.
|
Session#session{collect_timer = TRef}.
|
||||||
|
|
||||||
info(#session{clean_sess = CleanSess,
|
info(#session{clean_sess = CleanSess,
|
||||||
|
|
Loading…
Reference in New Issue