## org.red5.server
Class BasicScope

    java.lang.Object
      org.red5.server.AttributeStore
          org.red5.server.PersistableAttributeStore
              org.red5.server.BasicScope

All Implemented Interfaces:
  Iterable<IBasicScope>, AttributeStoreMBean, IEventDispatcher, IEventHandler, IEventListener, IEventObservable, IAttributeStore, IBasicScope, ICastingAttributeStore, ICoreObject, IPersistable

Direct Known Subclasses:
  BroadcastScope, Scope, SharedObjectScope

    public abstract class BasicScope

extends PersistableAttributeStore
implements IBasicScope

Generalizations of one of main Red5 object types, Scope. Basic scope is a persistable attribute store with event handling functionality

See Also:
  `IScope`, `Scope`

Nested Class Summary
`static class` `BasicScope.EmptyBasicScopeIterator` Iterator for basic scope

Field Summary
`protected int` `keepDelay` Set to amount of time (in seconds) the scope will be kept before being freed, after the last disconnect.
`protected boolean` `keepOnDisconnect` Set to true to prevent the scope from being freed upon disconnect.
`protected Set<IEventListener>` `listeners` List of event listeners
`protected IScope` `parent` Parent scope.
`protected String` `persistenceClass` Scope persistence storage type

Fields inherited from class org.red5.server.PersistableAttributeStore
`lastModified, name, path, persistent, store, type`

Fields inherited from class org.red5.server.AttributeStore
`attributes`

Fields inherited from interface org.red5.server.api.persistence.IPersistable
`TRANSIENT_PREFIX`

Constructor Summary
`BasicScope()` Creates unnamed scope
`BasicScope(IScope parent, String type, String name, boolean persistent)` Constructor for basic scope

Method Summary
`void` `addEventListener(IEventListener listener)` Add event listener to list of notified objects
`void` `dispatchEvent(IEvent event)` Dispatches event (notifies all listeners)
`int` `getDepth()` Get the scopes depth, how far down the scope tree is it.
`Iterator<IEventListener>` `getEventListeners()` Return listeners list iterator
`IScope` `getParent()` Get this scopes parent.
`String` `getPath()` Ruturn scope path
`boolean` `handleEvent(IEvent event)` Handles event.
`boolean` `hasEventListeners()` Returns true if there are event listeners attached to this scope.
`boolean` `hasParent()` Does this scope have a parent? You can think of scopes as of tree items where scope may have a parent and children (child).
`Iterator<IBasicScope>` `iterator()` Getter for subscopes list iterator.
`void` `notifyEvent(IEvent event)` Notifies listeners on event.
`void` `removeEventListener(IEventListener listener)` Remove event listener from list of listeners
`void` `setKeepDelay(int keepDelay)` Sets the amount of time to keep the scope available after the last disconnect.

Methods inherited from class org.red5.server.PersistableAttributeStore
`deserialize, getAttribute, getLastModified, getName, getStore, getType, isPersistent, modified, removeAttribute, removeAttributes, serialize, setAttribute, setAttributes, setAttributes, setName, setPath, setPersistent, setStore`

Methods inherited from class org.red5.server.AttributeStore
`filterNull, getAttribute, getAttributeNames, getAttributes, getBoolAttribute, getByteAttribute, getDoubleAttribute, getIntAttribute, getListAttribute, getLongAttribute, getMapAttribute, getSetAttribute, getShortAttribute, getStringAttribute, hasAttribute`

Methods inherited from class java.lang.Object
`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

Methods inherited from interface org.red5.server.api.IBasicScope
`getName, getType, lock, unlock`

Methods inherited from interface org.red5.server.api.ICastingAttributeStore
`getBoolAttribute, getByteAttribute, getDoubleAttribute, getIntAttribute, getListAttribute, getLongAttribute, getMapAttribute, getSetAttribute, getShortAttribute, getStringAttribute`

Methods inherited from interface org.red5.server.api.IAttributeStore
`getAttribute, getAttribute, getAttributeNames, getAttributes, hasAttribute, removeAttribute, removeAttributes, setAttribute, setAttributes, setAttributes`

Methods inherited from interface org.red5.server.api.persistence.IPersistable
`deserialize, getLastModified, getStore, isPersistent, serialize, setName, setPath, setPersistent, setStore`

Field Detail

### parent

    protected IScope parent

  Parent scope. Scopes can be nested.

  See Also:
    `IScope`

### listeners

    protected Set<IEventListener> listeners

  List of event listeners

### persistenceClass

    protected String persistenceClass

  Scope persistence storage type

### keepOnDisconnect

    protected boolean keepOnDisconnect

  Set to true to prevent the scope from being freed upon disconnect.

### keepDelay

    protected int keepDelay

  Set to amount of time (in seconds) the scope will be kept before being freed, after the last disconnect.

Constructor Detail

### BasicScope

    public BasicScope()

  Creates unnamed scope

### BasicScope

    public BasicScope(IScope parent,
                      String type,
                      String name,
                      boolean persistent)

  Constructor for basic scope

  Parameters:
    `parent` - Parent scope
    `type` - Scope type
    `name` - Scope name. Used to identify scopes in application, must be unique among scopes of one level
    `persistent` - Whether scope is persistent

Method Detail

### hasParent

    public boolean hasParent()

  Does this scope have a parent? You can think of scopes as of tree items where scope may have a parent and children (child).

  Specified by:
    `hasParent` in interface `IBasicScope`
  Returns:
    `true` if this scope has a parent, otherwise `false`

### getParent

    public IScope getParent()

  Get this scopes parent.

  Specified by:
    `getParent` in interface `IBasicScope`
  Returns:
    parent scope, or `null` if this scope doesn't have a parent

### getDepth

    public int getDepth()

  Get the scopes depth, how far down the scope tree is it. The lowest depth is 0x00, the depth of Global scope. Application scope depth is 0x01. Room depth is 0x02, 0x03 and so forth.

  Specified by:
    `getDepth` in interface `IBasicScope`
  Returns:
    the depth

### getPath

    public String getPath()

  Ruturn scope path

  Specified by:
    `getPath` in interface `IBasicScope`
  Specified by:
    `getPath` in interface `IPersistable`
  Overrides:
    `getPath` in class `PersistableAttributeStore`
  Returns:
    Path

### setKeepDelay

    public void setKeepDelay(int keepDelay)

  Sets the amount of time to keep the scope available after the last disconnect.

  Specified by:
    `setKeepDelay` in interface `IBasicScope`
  Parameters:
    `keepDelay` - delay

### addEventListener

    public void addEventListener(IEventListener listener)

  Add event listener to list of notified objects

  Specified by:
    `addEventListener` in interface `IEventObservable`
  Parameters:
    `listener` - Listening object

### removeEventListener

    public void removeEventListener(IEventListener listener)

  Remove event listener from list of listeners

  Specified by:
    `removeEventListener` in interface `IEventObservable`
  Parameters:
    `listener` - Listener to remove

### getEventListeners

    public Iterator<IEventListener> getEventListeners()

  Return listeners list iterator

  Specified by:
    `getEventListeners` in interface `IEventObservable`
  Returns:
    Listeners list iterator

### hasEventListeners

    public boolean hasEventListeners()

  Returns true if there are event listeners attached to this scope.

  Returns:
    true if it has listeners; else false.

### handleEvent

    public boolean handleEvent(IEvent event)

  Handles event. To be implemented in subclass realization

  Specified by:
    `handleEvent` in interface `IEventHandler`
  Parameters:
    `event` - Event context
  Returns:
    Event handling result

### notifyEvent

    public void notifyEvent(IEvent event)

  Notifies listeners on event. Current implementation is empty. To be implemented in subclass realization

  Specified by:
    `notifyEvent` in interface `IEventListener`
  Parameters:
    `event` - Event to broadcast

### dispatchEvent

    public void dispatchEvent(IEvent event)

  Dispatches event (notifies all listeners)

  Specified by:
    `dispatchEvent` in interface `IEventDispatcher`
  Parameters:
    `event` - Event to dispatch

### iterator

    public Iterator<IBasicScope> iterator()

  Getter for subscopes list iterator. Returns null because this is a base implementation

  Specified by:
    `iterator` in interface `Iterable<IBasicScope>`
  Returns:
    Iterator for subscopes

Copyright © 2006-2010 The Red5 Project