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
Nested ClassesModifier and TypeClassDescriptionprivate classKeeps the scope alive for a set number of seconds. -
Field Summary
FieldsModifier and TypeFieldDescriptionprotected longCreation timestampprivate StringScheduled job name for keep alive checkprotected intSet to amount of time (in seconds) the scope will be kept before being freed, after the last disconnect.protected booleanSet to true to prevent the scope from being freed upon disconnect.protected CopyOnWriteArraySet<IEventListener>List of event listenersprotected static org.slf4j.Loggerprotected StringString identifier for this scopeprotected IScopeParent scope.protected StringScope persistence storage typeprotected booleanWhether or not to persist attributesprotected CopyOnWriteArraySet<IScopeSecurityHandler>List of security handlersprotected IPersistenceStoreStorage for persistable attributesprotected ScopeTypeScope type. -
Constructor Summary
ConstructorsConstructorDescriptionCreates unnamed scopeBasicScope(IScope parent, ScopeType type, String name, boolean persistent) Constructor for basic scope -
Method Summary
Modifier and TypeMethodDescriptionbooleanaddEventListener(IEventListener listener) Add event listener to list of notified objectsintcompareTo(BasicScope that) voiddispatchEvent(IEvent event) Dispatches event (notifies all listeners)booleanEquality is based on the scope's name and type.intgetDepth()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.booleanhandleEvent(IEvent event) Handles event.booleanReturns true if there are event listeners attached to this scope.inthashCode()Hash code is based on the scope's name and typebooleanDoes this scope have a parent? You can think of scopes as of tree items where scope may have a parent and children (child).booleanProvides a means to allow a scope to perform processing on a connection prior to the actual connection attempt or other handling.booleanisScopeAllowed(IScope scope) Provides a means to allow a scope to perform processing on another scope prior to additional scope handling.booleanisValid()Validates a scope based on its name and typevoidnotifyEvent(IEvent event) Notifies listeners on event.booleanremoveEventListener(IEventListener listener) Remove event listener from list of listenersvoidsetKeepDelay(int keepDelay) Sets the amount of time to keep the scope available after the last disconnect.voidsetSecurityHandlers(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:
hasParentin interfaceIBasicScope- Returns:
- true if this scope has a parent, otherwise false
-
getParent
Get this scopes parent.- Specified by:
getParentin interfaceIBasicScope- Returns:
- parent scope, or null if this scope doesn't have a parent
-
getType
Description copied from interface:IBasicScopeGet the type of the scope.- Specified by:
getTypein interfaceIBasicScope- Returns:
- the type
-
getName
Description copied from interface:IBasicScopeGet the name of this scope. Eg. someroom- Specified by:
getNamein interfaceIBasicScope- Returns:
- the name
-
getStore
Description copied from interface:IBasicScopeGet the persistable store- Specified by:
getStorein 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:
getDepthin interfaceIBasicScope- Returns:
- the depth
-
getPath
Get the full absolute path. Eg. host / myapp / someroom- Specified by:
getPathin 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:
setKeepDelayin interfaceIBasicScope- Parameters:
keepDelay- delay
-
isValid
public boolean isValid()Validates a scope based on its name and type- Specified by:
isValidin 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:
isConnectionAllowedin 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:
isScopeAllowedin 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:
setSecurityHandlersin interfaceIBasicScope- Parameters:
handlers- scope security handlers
-
addEventListener
Add event listener to list of notified objects- Specified by:
addEventListenerin interfaceIEventObservable- Parameters:
listener- Listening object- Returns:
- true if listener is added and false otherwise
-
removeEventListener
Remove event listener from list of listeners- Specified by:
removeEventListenerin interfaceIEventObservable- Parameters:
listener- Listener to remove- Returns:
- true if listener is removed and false otherwise
-
getEventListeners
Return listeners list iterator- Specified by:
getEventListenersin 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:
handleEventin 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:
notifyEventin interfaceIEventListener- Parameters:
event- Event to broadcast
-
dispatchEvent
Dispatches event (notifies all listeners)- Specified by:
dispatchEventin 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:
compareToin interfaceComparable<BasicScope>
-