Class BroadcastScope

java.lang.Object
org.red5.server.scope.BasicScope
org.red5.server.scope.BroadcastScope
All Implemented Interfaces:
Comparable<BasicScope>, IEventDispatcher, IEventHandler, IEventListener, IEventObservable, ICoreObject, IBasicScope, IBroadcastScope, IMessageInput, IMessageOutput, IPipe, IPipeConnectionListener

public class BroadcastScope extends BasicScope implements IBroadcastScope, IPipeConnectionListener
Scope type for publishing that deals with pipe connection events, like async message listening in JMS
  • Field Details

    • clientBroadcastStream

      private transient IClientBroadcastStream clientBroadcastStream
      Broadcasting stream associated with this scope
    • pipe

      private final transient InMemoryPushPushPipe pipe
      Simple in memory push pipe, triggered by an active provider to push messages to consumer
    • compCounter

      private AtomicInteger compCounter
      Number of components.
    • removed

      private volatile boolean removed
      Whether or not this "scope" has been removed
  • Constructor Details

    • BroadcastScope

      public BroadcastScope(IScope parent, String name)
      Creates broadcast scope
      Parameters:
      parent - Parent scope
      name - Scope name
  • Method Details

    • addPipeConnectionListener

      public void addPipeConnectionListener(IPipeConnectionListener listener)
      Register pipe connection event listener with this scope's pipe. A listener that wants to listen to events when provider/consumer connects to or disconnects from a specific pipe.
      Specified by:
      addPipeConnectionListener in interface IPipe
      Parameters:
      listener - Pipe connection event listener
      See Also:
    • removePipeConnectionListener

      public void removePipeConnectionListener(IPipeConnectionListener listener)
      Unregisters pipe connection event listener with this scope's pipe
      Specified by:
      removePipeConnectionListener in interface IPipe
      Parameters:
      listener - Pipe connection event listener
      See Also:
    • pullMessage

      public IMessage pullMessage()
      Pull message from pipe
      Specified by:
      pullMessage in interface IMessageInput
      Returns:
      Message object
      See Also:
    • pullMessage

      public IMessage pullMessage(long wait)
      Pull message with timeout
      Specified by:
      pullMessage in interface IMessageInput
      Parameters:
      wait - Timeout
      Returns:
      Message object
      See Also:
    • subscribe

      public boolean subscribe(IConsumer consumer, Map<String,Object> paramMap)
      Connect scope's pipe to given consumer
      Specified by:
      subscribe in interface IMessageInput
      Parameters:
      consumer - Consumer
      paramMap - Parameters passed with connection
      Returns:
      true on success, false otherwise
    • unsubscribe

      public boolean unsubscribe(IConsumer consumer)
      Disconnects scope's pipe from given consumer
      Specified by:
      unsubscribe in interface IMessageInput
      Parameters:
      consumer - Consumer
      Returns:
      true on success, false otherwise
    • getConsumers

      public List<IConsumer> getConsumers()
      Getter for pipe consumers
      Specified by:
      getConsumers in interface IMessageInput
      Returns:
      Pipe consumers
    • sendOOBControlMessage

      public void sendOOBControlMessage(IConsumer consumer, OOBControlMessage oobCtrlMsg)
      Send out-of-band ("special") control message
      Specified by:
      sendOOBControlMessage in interface IMessageInput
      Parameters:
      consumer - Consumer, may be used in concrete implementations
      oobCtrlMsg - Out-of-band control message
    • pushMessage

      public void pushMessage(IMessage message) throws IOException
      Push a message to this output endpoint. May block the pusher when output can't handle the message at the time.
      Specified by:
      pushMessage in interface IMessageOutput
      Parameters:
      message - Message to be pushed
      Throws:
      IOException - If message could not be pushed
    • subscribe

      public boolean subscribe(IProvider provider, Map<String,Object> paramMap)
      Connect scope's pipe with given provider
      Specified by:
      subscribe in interface IMessageOutput
      Parameters:
      provider - Provider
      paramMap - Parameters passed on connection
      Returns:
      true on success, false otherwise
    • unsubscribe

      public boolean unsubscribe(IProvider provider)
      Disconnects scope's pipe from given provider
      Specified by:
      unsubscribe in interface IMessageOutput
      Parameters:
      provider - Provider
      Returns:
      true on success, false otherwise
    • getProviders

      public List<IProvider> getProviders()
      Getter for providers list
      Specified by:
      getProviders in interface IMessageOutput
      Returns:
      List of providers
    • sendOOBControlMessage

      public void sendOOBControlMessage(IProvider provider, OOBControlMessage oobCtrlMsg)
      Send out-of-band ("special") control message
      Specified by:
      sendOOBControlMessage in interface IMessageOutput
      Parameters:
      provider - Provider, may be used in concrete implementations
      oobCtrlMsg - Out-of-band control message
    • onPipeConnectionEvent

      public void onPipeConnectionEvent(PipeConnectionEvent event)
      Pipe connection event handler
      Specified by:
      onPipeConnectionEvent in interface IPipeConnectionListener
      Parameters:
      event - Pipe connection event
    • getClientBroadcastStream

      public IClientBroadcastStream getClientBroadcastStream()
      Returns the client broadcast stream
      Specified by:
      getClientBroadcastStream in interface IBroadcastScope
    • setClientBroadcastStream

      public void setClientBroadcastStream(IClientBroadcastStream clientBroadcastStream)
      Sets the client broadcast stream
      Specified by:
      setClientBroadcastStream in interface IBroadcastScope
      Parameters:
      clientBroadcastStream - stream
    • toString

      public String toString()
      Overrides:
      toString in class Object