code: public IoBuffer encode(Object message) throws Exception {
          if (message != null) {
              try {
                  return encodePacket((Packet) message);
              } catch (Exception e) {
                  log.error("Error encoding", e);
              }
          } else if (log.isDebugEnabled()) {
              try {
                  String callingMethod = Thread.currentThread().getStackTrace()[4].getMethodName();
                  log.debug("Message is null at encode, expecting a Packet from: {}", callingMethod);
              } catch (Throwable t) {
                  log.warn("Problem getting current calling method from stacktrace", t);
              }
          }
          return null;
      }
docs: Encodes object with given protocol state to byte buffer
  
  @param message
  Object to encode
  @return IoBuffer with encoded data
  @throws Exception
  Any decoding exception