isValidCloseCode function
Whether code is one a peer may send in a close frame (RFC 6455 7.4
and the IANA registry).
1005, 1006 and 1015 are reserved for local use and 1004 is not defined.
Implementation
bool isValidCloseCode(int code) =>
(code >= 1000 && code <= 1003) ||
(code >= 1007 && code <= 1014) ||
(code >= 3000 && code <= 4999);