Limit output messages to hardcoded char limit to avoid overtly long messages being cut by the server
This commit is contained in:
parent
fb7d86c9fd
commit
4cb854e94c
1 changed files with 10 additions and 2 deletions
|
@ -6,6 +6,14 @@ defmodule Nulform.Connection do
|
|||
Connection automatically handles using an altnick (but only one) and
|
||||
responding to pings.
|
||||
"""
|
||||
|
||||
@doc """
|
||||
Message max length excluding CRLF. This is smaller than the RFC specifies
|
||||
(510) to accommodate for a potentially long hostmask which will take up
|
||||
space in the message.
|
||||
"""
|
||||
@max_len 440
|
||||
|
||||
defrecord Data,
|
||||
handler: nil,
|
||||
buffer: nil,
|
||||
|
@ -111,8 +119,8 @@ defmodule Nulform.Connection do
|
|||
end
|
||||
|
||||
defp send_raw(data, msg) do
|
||||
:ok = :gen_tcp.send data.sock, msg <> "\r\n"
|
||||
IO.puts(to_binary(data.id) <> " <- " <> msg)
|
||||
:ok = :gen_tcp.send data.sock, String.slice(msg, 0, @max_len) <> "\r\n"
|
||||
IO.puts(to_binary(data.id) <> " <- " <> String.slice(msg, 0, @max_len))
|
||||
end
|
||||
|
||||
defp tell_handler(data, msg) do
|
||||
|
|
Loading…
Reference in a new issue