code: protected static void checkMessageSize(Object message, long maxMessageSize) {
          if (maxMessageSize != -1) {
              final long messageSize =
                      (message instanceof String ? ((String) message).getBytes(Charset.defaultCharset()).length
                              : ((ByteBuffer) message).remaining());
  
              if (messageSize > maxMessageSize) {
                  throw new MessageTooBigException(
                          Messages.get("web.socket.error.message.too.long", maxMessageSize, messageSize)
                  );
              }
          }
      }
docs: <p>checkMessageSize.</p>
  
  @param message        a {@link java.lang.Object} object.
  @param maxMessageSize a long.