org.red5.server.scope

## Class BroadcastScope

- java.lang.Object
- - org.red5.server.scope.BasicScope
  - - org.red5.server.scope.BroadcastScope

All Implemented Interfaces:
  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 Summary

Fields
`protected Lock` `lock` Lock for critical sections, to prevent concurrent modification.

### Fields inherited from class org.red5.server.scope.BasicScope

`keepDelay, keepOnDisconnect, listeners, name, parent, persistenceClass, persistent, store, type`

### Constructor Summary

Constructors
Constructor and Description
`BroadcastScope(IScope parent, String name)` Creates broadcast scope

### Method Summary

Methods
`void` `addPipeConnectionListener(IPipeConnectionListener listener)` Register pipe connection event listener with this scope's pipe.
`IClientBroadcastStream` `getClientBroadcastStream()` Returns the client broadcast stream
`List<IConsumer>` `getConsumers()` Getter for pipe consumers
`List<IProvider>` `getProviders()` Getter for providers list
`void` `lock()`
`void` `onPipeConnectionEvent(PipeConnectionEvent event)` Pipe connection event handler
`IMessage` `pullMessage()` Pull message from pipe
`IMessage` `pullMessage(long wait)` Pull message with timeout
`void` `pushMessage(IMessage message)` Push a message to this output endpoint.
`void` `removePipeConnectionListener(IPipeConnectionListener listener)` Unregisters pipe connection event listener with this scope's pipe
`void` `sendOOBControlMessage(IConsumer consumer, OOBControlMessage oobCtrlMsg)` Send out-of-band ("special") control message
`void` `sendOOBControlMessage(IProvider provider, OOBControlMessage oobCtrlMsg)` Send out-of-band ("special") control message
`void` `setClientBroadcastStream(IClientBroadcastStream clientBroadcastStream)` Sets the client broadcast stream
`boolean` `subscribe(IConsumer consumer, Map<String,Object> paramMap)` Connect scope's pipe to given consumer
`boolean` `subscribe(IProvider provider, Map<String,Object> paramMap)` Connect scope's pipe with given provider
`void` `unlock()`
`boolean` `unsubscribe(IConsumer consumer)` Disconnects scope's pipe from given consumer
`boolean` `unsubscribe(IProvider provider)` Disconnects scope's pipe from given provider

### Methods inherited from class org.red5.server.scope.BasicScope

`addEventListener, dispatchEvent, equals, getDepth, getEventListeners, getName, getParent, getPath, getStore, getType, handleEvent, hasEventListeners, hashCode, hasParent, isValid, notifyEvent, removeEventListener, setKeepDelay`

### Methods inherited from class java.lang.Object

`clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait`

### Methods inherited from interface org.red5.server.api.scope.IBasicScope

`getDepth, getName, getParent, getPath, getStore, getType, hasParent, isValid, setKeepDelay`

### Methods inherited from interface org.red5.server.api.event.IEventDispatcher

`dispatchEvent`

### Methods inherited from interface org.red5.server.api.event.IEventHandler

`handleEvent`

### Methods inherited from interface org.red5.server.api.event.IEventListener

`notifyEvent`

### Methods inherited from interface org.red5.server.api.event.IEventObservable

`addEventListener, getEventListeners, removeEventListener`

### Field Detail

#### lock

    protected Lock lock

Lock for critical sections, to prevent concurrent modification. A "fairness" policy is used wherein the longest waiting thread will be granted access before others.

### Constructor Detail

#### BroadcastScope

    public BroadcastScope(IScope parent,
                  String name)

Creates broadcast scope

Parameters:
  `parent` - Parent scope
  `name` - Scope name

### Method Detail

#### 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:
  `IPipeConnectionListener`

#### 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:
  `IPipeConnectionListener`

#### pullMessage

    public IMessage pullMessage()

Pull message from pipe

Specified by:
  `pullMessage` in interface `IMessageInput`
Returns:
  Message object
See Also:
  `IMessage`

#### pullMessage

    public IMessage pullMessage(long wait)

Pull message with timeout

Specified by:
  `pullMessage` in interface `IMessageInput`
Parameters:
  `wait` - Timeout
Returns:
  Message object
See Also:
  `IMessage`

#### 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

#### lock

    public void lock()

#### unlock

    public void unlock()

#### 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` -