Package org.red5.server.scope
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
Generalizations of one of main Red5 object types, Scope.
-
Nested Class Summary
Modifier and TypeClassDescriptionprivate class
Keeps the scope alive for a set number of seconds. -
Field Summary
Modifier and TypeFieldDescriptionprotected long
Creation timestampprivate String
Scheduled job name for keep alive checkprotected int
Set to amount of time (in seconds) the scope will be kept before being freed, after the last disconnect.protected boolean
Set to true to prevent the scope from being freed upon disconnect.protected CopyOnWriteArraySet<IEventListener>
List of event listenersprotected static org.slf4j.Logger
protected String
String identifier for this scopeprotected IScope
Parent scope.protected String
Scope persistence storage typeprotected boolean
Whether or not to persist attributesprotected CopyOnWriteArraySet<IScopeSecurityHandler>
List of security handlersprotected IPersistenceStore
Storage for persistable attributesprotected ScopeType
Scope type. -
Constructor Summary
ConstructorDescriptionCreates unnamed scopeBasicScope
(IScope parent, ScopeType type, String name, boolean persistent) Constructor for basic scope -
Method Summary
Modifier and TypeMethodDescriptionboolean
addEventListener
(IEventListener listener) Add event listener to list of notified objectsint
compareTo
(BasicScope that) void
dispatchEvent
(IEvent event) Dispatches event (notifies all listeners)boolean
Equality is based on the scope's name and type.int
getDepth()
Get the scopes depth, how far down the scope tree is it.Return listeners list iteratorgetName()
Get the name of this scope.Get this scopes parent.getPath()
Get the full absolute path.getStore()
Get the persistable storegetType()
Get the type of the scope.boolean
handleEvent
(IEvent event) Handles event.boolean
Returns true if there are event listeners attached to this scope.int
hashCode()
Hash code is based on the scope's name and typeboolean
Does this scope have a parent? You can think of scopes as of tree items where scope may have a parent and children (child).boolean
Provides a means to allow a scope to perform processing on a connection prior to the actual connection attempt or other handling.boolean
isScopeAllowed
(IScope scope) Provides a means to allow a scope to perform processing on another scope prior to additional scope handling.boolean
isValid()
Validates a scope based on its name and typevoid
notifyEvent
(IEvent event) Notifies listeners on event.boolean
removeEventListener
(IEventListener listener) Remove event listener from list of listenersvoid
setKeepDelay
(int keepDelay) Sets the amount of time to keep the scope available after the last disconnect.void
setSecurityHandlers
(Set<IScopeSecurityHandler> handlers) Sets the scope security handlers.
-
Field Details
-
log
protected static org.slf4j.Logger log -
keepAliveJobName
Scheduled job name for keep alive check -
parent
Parent scope. Scopes can be nested.- See Also:
-
type
Scope type.- See Also:
-
name
String identifier for this scope -
creation
protected long creationCreation timestamp -
persistent
protected boolean persistentWhether or not to persist attributes -
store
Storage for persistable attributes -
persistenceClass
Scope persistence storage type -
keepOnDisconnect
protected boolean keepOnDisconnectSet to true to prevent the scope from being freed upon disconnect. -
keepDelay
protected int keepDelaySet to amount of time (in seconds) the scope will be kept before being freed, after the last disconnect. -
securityHandlers
List of security handlers -
listeners
List of event listeners
-
-
Constructor Details
-
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 scopetype
- Scope typename
- Scope name. Used to identify scopes in application, must be unique among scopes of one levelpersistent
- 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 interfaceIBasicScope
- Returns:
- true if this scope has a parent, otherwise false
-
getParent
Get this scopes parent.- Specified by:
getParent
in interfaceIBasicScope
- Returns:
- parent scope, or null if this scope doesn't have a parent
-
getType
Description copied from interface:IBasicScope
Get the type of the scope.- Specified by:
getType
in interfaceIBasicScope
- Returns:
- the type
-
getName
Description copied from interface:IBasicScope
Get the name of this scope. Eg. someroom- Specified by:
getName
in interfaceIBasicScope
- Returns:
- the name
-
getStore
Description copied from interface:IBasicScope
Get the persistable store- Specified by:
getStore
in interfaceIBasicScope
- 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 interfaceIBasicScope
- Returns:
- the depth
-
getPath
Get the full absolute path. Eg. host / myapp / someroom- Specified by:
getPath
in interfaceIBasicScope
- 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 interfaceIBasicScope
- Parameters:
keepDelay
- delay
-
isValid
public boolean isValid()Validates a scope based on its name and type- Specified by:
isValid
in interfaceIBasicScope
- Returns:
- true if both name and type are valid, false otherwise
-
isConnectionAllowed
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 interfaceIBasicScope
- Parameters:
conn
- connection- Returns:
- true if connection is allowed and false if it is not allowed
-
isScopeAllowed
Provides a means to allow a scope to perform processing on another scope prior to additional scope handling.- Specified by:
isScopeAllowed
in interfaceIBasicScope
- Parameters:
scope
- scope- Returns:
- true if scope is allowed and false if it is not allowed
-
setSecurityHandlers
Sets the scope security handlers.- Specified by:
setSecurityHandlers
in interfaceIBasicScope
- Parameters:
handlers
- scope security handlers
-
addEventListener
Add event listener to list of notified objects- Specified by:
addEventListener
in interfaceIEventObservable
- Parameters:
listener
- Listening object- Returns:
- true if listener is added and false otherwise
-
removeEventListener
Remove event listener from list of listeners- Specified by:
removeEventListener
in interfaceIEventObservable
- Parameters:
listener
- Listener to remove- Returns:
- true if listener is removed and false otherwise
-
getEventListeners
Return listeners list iterator- Specified by:
getEventListeners
in interfaceIEventObservable
- 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
Handles event. To be implemented in subclass realization- Specified by:
handleEvent
in interfaceIEventHandler
- Parameters:
event
- Event context- Returns:
- Event handling result
-
notifyEvent
Notifies listeners on event. Current implementation is empty. To be implemented in subclass realization- Specified by:
notifyEvent
in interfaceIEventListener
- Parameters:
event
- Event to broadcast
-
dispatchEvent
Dispatches event (notifies all listeners)- Specified by:
dispatchEvent
in interfaceIEventDispatcher
- Parameters:
event
- Event to dispatch
-
hashCode
public int hashCode()Hash code is based on the scope's name and type -
equals
Equality is based on the scope's name and type. -
compareTo
- Specified by:
compareTo
in interfaceComparable<BasicScope>
-