public int invoke(Msg msg, MsgContext ep) throws IOException {
    int type = msg.peekByte();
    ep.setType(type);

    if (type > handlers.length || handlers[type] == null) {
      if (log.isDebugEnabled()) log.debug("Invalid handler " + type);
      return ERROR;
    }

    if (log.isDebugEnabled()) log.debug("Received " + type + " " + handlers[type].getName());

    JkHandler handler = handlers[type];

    return handler.invoke(msg, ep);
  }