Skip to content

Instantly share code, notes, and snippets.

@matehat
Forked from CharlesOkwuagwu/too_many_warnings.ex
Created February 28, 2016 17:12
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save matehat/94ea16970fead2c3135d to your computer and use it in GitHub Desktop.
Save matehat/94ea16970fead2c3135d to your computer and use it in GitHub Desktop.
too many warnings
defp send_messages(msg_list, s, do_timer_reset) do
if do_timer_reset do
if s.acks != [] do
ids = s.acks
s = %{s | acks: []}
log "adding acks: #{inspect ids}"
msg_list = msg_list ++ [{TL.msgs_ack(ids), false}]
end
# if s.resends != [] do
# ids = s.resends
# s = %{s | resends: []}
# log "adding resends: #{inspect ids}"
# msg_list = msg_list ++ [{TL.msg_resend_req(ids), false}]
# end
:timer.cancel(s.ack_timer)
end
if length(msg_list) > 1 do
{content_count, prev_msg_id, msg} = pack_messages(msg_list, 0, "", s.content_count, s.prev_msg_id)
send_enc(seq_no(content_count, false), message_id(prev_msg_id + 8), content_count, msg, s)
else
{msg, is_content} = hd(msg_list)
if is_content == true do
send_enc(seq_no(s.content_count, true), message_id(s.prev_msg_id + 8), s.content_count + 1, msg, s)
else
send_enc(seq_no(s.content_count, false), message_id(s.prev_msg_id + 8), s.content_count, msg, s)
end
end
end
@CharlesOkwuagwu
Copy link

Could you find a way to rewrite this better?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment