Reformat code

This commit is contained in:
Maciej Szlosarczyk 2019-07-11 10:06:16 +03:00
parent e867e15ce7
commit f17613b5f7
No known key found for this signature in database
GPG key ID: 41D62D42D3B0D765

View file

@ -98,9 +98,9 @@ handle_cast(process_command,
%% Else, go back to the beginning of the loop. %% Else, go back to the beginning of the loop.
if Command =:= "logout" -> if Command =:= "logout" ->
case gen_tcp:shutdown(Socket, read_write) of case gen_tcp:shutdown(Socket, read_write) of
ok -> {stop, normal, State}; ok -> {stop, normal, State};
{error, closed} -> {stop, normal, State} {error, closed} -> {stop, normal, State}
end; end;
true -> true ->
gen_server:cast(self(), process_command), gen_server:cast(self(), process_command),
{noreply, {noreply,
@ -135,13 +135,13 @@ state_from_socket(Socket, State) ->
frame_from_socket(Socket, State) -> frame_from_socket(Socket, State) ->
case gen_tcp:recv(Socket, 0, ?DefaultTimeout) of case gen_tcp:recv(Socket, 0, ?DefaultTimeout) of
{ok, Data} -> {ok, Data} ->
EPPEnvelope = binary:part(Data, {0, 4}), EPPEnvelope = binary:part(Data, {0, 4}),
ReportedLength = binary:decode_unsigned(EPPEnvelope, ReportedLength = binary:decode_unsigned(EPPEnvelope,
big), big),
read_until_exhausted(Socket, ReportedLength, Data); read_until_exhausted(Socket, ReportedLength, Data);
{error, closed} -> log_and_exit(State); {error, closed} -> log_and_exit(State);
{error, timeout} -> log_on_timeout(State) {error, timeout} -> log_on_timeout(State)
end. end.
%% When an EPP message is long, it will be received in smaller chunks. %% When an EPP message is long, it will be received in smaller chunks.
@ -156,7 +156,8 @@ read_until_exhausted(Socket, ExpectedLength, Frame) ->
binary:part(Frame, binary:part(Frame,
{byte_size(Frame), 4 - ExpectedLength}); {byte_size(Frame), 4 - ExpectedLength});
ExpectedLength > byte_size(Frame) -> ExpectedLength > byte_size(Frame) ->
{ok, NextFrame} = gen_tcp:recv(Socket, 0, ?DefaultTimeout), {ok, NextFrame} = gen_tcp:recv(Socket, 0,
?DefaultTimeout),
NewFrame = <<Frame/binary, NextFrame/binary>>, NewFrame = <<Frame/binary, NextFrame/binary>>,
read_until_exhausted(Socket, ExpectedLength, NewFrame) read_until_exhausted(Socket, ExpectedLength, NewFrame)
end. end.