code: @Override
      public void write(final Packet packet) {
          log.debug("write - state: {}", state);
          if (closing || state.getState() == RTMP.STATE_DISCONNECTED) {
              // Connection is being closed, don't send any new packets
              return;
          }
          IoBuffer data;
          try {
              Red5.setConnectionLocal(this);
              data = encoder.encode(packet);
          } catch (Exception e) {
              log.error("Could not encode message {}", packet, e);
              return;
          } finally {
              Red5.setConnectionLocal(null);
          }
  
          if (data != null) {
              // Mark packet as being written
              writingMessage(packet);
              //add to pending
              pendingMessages.add(new PendingData(data, packet));
          } else {
              log.info("Response buffer was null after encoding");
          }
      }
docs: Send RTMP packet down the connection.
  
  @param packet
  the packet to send