Discovered that Freenode (seems to) drops te last char that is
technically still able to be sent in the 510 bytes buffer size that is
defined by IRC spec. Tested on hackint, efnet, dalnet and all give
expected results, except for Freenode.
Added safety-net of 5 bytes such that OTR and other tools that depend on
max possible message don't suffer from bad IRC server implementation.
Also, added logger.warn message in case too large message is sent.
Message is still sent, but a warning message shows up in the console.
This is most useful for debugging issues with additional plugins such as
transform plugins. We cannot display a partial message as it may have
been transformed during the send process.
Added use for SAFETY_NET constant in BasicPollerPresenceWatcher where
max possible message size calculation is used.
Improved error handling in several ways:
1. Recognize problems while connecting and don't treat these as an
unknown error. Instead catch them and simply handle them as a normal
exception that occurs during the connection process without extra
logging.
2. irc-api was improved with another message type. This type is signaled
from the client library itself and functions as a mechanism for
informing registered listeners of problems after-the-fact. For example,
in case a connection was interrupted unannounced and there is no other
way for a server message to arrive to signal for an error. This
mechanism uses the message dispatching infrastructure to dispatch a
message containing an exception such that listeners can be updated of
connection problems. This mechanism will be used for signaling "fatal"
errors only, i.e. if the connection is broken for sure and we cannot
expect the server to reach us such that we can receive an error message.
(Or any kind of message, for that matter)