Class BasicScope

java.lang.Object
org.red5.server.scope.BasicScope
All Implemented Interfaces:
Comparable<BasicScope>, IEventDispatcher, IEventHandler, IEventListener, IEventObservable, ICoreObject, IBasicScope
Direct Known Subclasses:
BroadcastScope, Scope

public abstract class BasicScope extends Object implements IBasicScope, Comparable<BasicScope>
Generalizations of one of main Red5 object types, Scope.
See Also:
  • Field Details

    • log

      protected static org.slf4j.Logger log
    • keepAliveJobName

      private String keepAliveJobName
      Scheduled job name for keep alive check
    • parent

      protected IScope parent
      Parent scope. Scopes can be nested.
      See Also:
    • type

      protected ScopeType type
      Scope type.
      See Also:
    • name

      protected String name
      String identifier for this scope
    • creation

      protected long creation
      Creation timestamp
    • persistent

      protected boolean persistent
      Whether or not to persist attributes
    • store

      protected IPersistenceStore store
      Storage for persistable attributes
    • 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.
    • securityHandlers

      protected transient CopyOnWriteArraySet<IScopeSecurityHandler> securityHandlers
      List of security handlers
    • listeners

      protected transient CopyOnWriteArraySet<IEventListener> listeners
      List of event listeners
  • Constructor Details

    • BasicScope

      @ConstructorProperties("") public BasicScope()
      Creates unnamed scope
    • BasicScope

      @ConstructorProperties({"parent","type","name","persistent"}) public BasicScope(IScope parent, ScopeType 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 Details

    • 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
    • getType

      public ScopeType getType()
      Description copied from interface: IBasicScope
      Get the type of the scope.
      Specified by:
      getType in interface IBasicScope
      Returns:
      the type
    • getName

      public String getName()
      Description copied from interface: IBasicScope
      Get the name of this scope. Eg. someroom
      Specified by:
      getName in interface IBasicScope
      Returns:
      the name
    • getStore

      public IPersistenceStore getStore()
      Description copied from interface: IBasicScope
      Get the persistable store
      Specified by:
      getStore in interface IBasicScope
      Returns:
      the store
    • 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()
      Get the full absolute path. Eg. host / myapp / someroom
      Specified by:
      getPath in interface IBasicScope
      Returns:
      absolute scope 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
    • isValid

      public boolean isValid()
      Validates a scope based on its name and type
      Specified by:
      isValid in interface IBasicScope
      Returns:
      true if both name and type are valid, false otherwise
    • isConnectionAllowed

      public boolean isConnectionAllowed(IConnection conn)
      Provides a means to allow a scope to perform processing on a connection prior to the actual connection attempt or other handling.
      Specified by:
      isConnectionAllowed in interface IBasicScope
      Parameters:
      conn - connection
      Returns:
      true if connection is allowed and false if it is not allowed
    • isScopeAllowed

      public boolean isScopeAllowed(IScope scope)
      Provides a means to allow a scope to perform processing on another scope prior to additional scope handling.
      Specified by:
      isScopeAllowed in interface IBasicScope
      Parameters:
      scope - scope
      Returns:
      true if scope is allowed and false if it is not allowed
    • setSecurityHandlers

      public void setSecurityHandlers(Set<IScopeSecurityHandler> handlers)
      Sets the scope security handlers.
      Specified by:
      setSecurityHandlers in interface IBasicScope
      Parameters:
      handlers - scope security handlers
    • addEventListener

      public boolean addEventListener(IEventListener listener)
      Add event listener to list of notified objects
      Specified by:
      addEventListener in interface IEventObservable
      Parameters:
      listener - Listening object
      Returns:
      true if listener is added and false otherwise
    • removeEventListener

      public boolean removeEventListener(IEventListener listener)
      Remove event listener from list of listeners
      Specified by:
      removeEventListener in interface IEventObservable
      Parameters:
      listener - Listener to remove
      Returns:
      true if listener is removed and false otherwise
    • getEventListeners

      public Set<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
    • hashCode

      public int hashCode()
      Hash code is based on the scope's name and type
      Overrides:
      hashCode in class Object
      Returns:
      hash code
    • equals

      public boolean equals(Object obj)
      Equality is based on the scope's name and type.
      Overrides:
      equals in class Object
      Parameters:
      obj - object
    • compareTo

      public int compareTo(BasicScope that)
      Specified by:
      compareTo in interface Comparable<BasicScope>