Package org.red5.server.so
Class ClientSharedObject
java.lang.Object
org.red5.server.AttributeStore
org.red5.server.so.SharedObject
org.red5.server.so.ClientSharedObject
- All Implemented Interfaces:
IEventDispatcher,IAttributeStore,ICastingAttributeStore,IPersistable,IServiceHandlerProvider,IClientSharedObject,ISharedObjectBase,ISharedObjectHandlerProvider,ISharedObjectStatistics,IStatisticsBase,AttributeStoreMXBean,Constants
public class ClientSharedObject
extends SharedObject
implements IClientSharedObject, IEventDispatcher
Works with client-side shared object
-
Nested Class Summary
Nested classes/interfaces inherited from interface org.red5.server.net.rtmp.message.Constants
Constants.DataType -
Field Summary
FieldsFields inherited from class org.red5.server.so.SharedObject
acquireCount, changeStats, closed, deleteStats, lastModified, listenerStats, name, ownerMessage, path, persistent, sendStats, source, storage, syncEvents, updateCounter, versionFields inherited from class org.red5.server.AttributeStore
attributes, isDebug, isTraceFields inherited from interface org.red5.server.net.rtmp.message.Constants
HANDSHAKE_SIZE, HEADER_CONTINUE, HEADER_NEW, HEADER_SAME_SOURCE, HEADER_TIMER_CHANGE, MEDIUM_INT_MAX, SO_CLIENT_CLEAR_DATA, SO_CLIENT_DELETE_DATA, SO_CLIENT_INITIAL_DATA, SO_CLIENT_SEND_MESSAGE, SO_CLIENT_STATUS, SO_CLIENT_UPDATE_ATTRIBUTE, SO_CLIENT_UPDATE_DATA, SO_CONNECT, SO_DELETE_ATTRIBUTE, SO_DISCONNECT, SO_SEND_MESSAGE, SO_SET_ATTRIBUTE, SOURCE_TYPE_LIVE, SOURCE_TYPE_VOD, TYPE_ABORT, TYPE_AGGREGATE, TYPE_AUDIO_DATA, TYPE_BYTES_READ, TYPE_CHUNK_SIZE, TYPE_CLIENT_BANDWIDTH, TYPE_EDGE_ORIGIN, TYPE_FLEX_MESSAGE, TYPE_FLEX_SHARED_OBJECT, TYPE_FLEX_STREAM_SEND, TYPE_INVOKE, TYPE_NOTIFY, TYPE_PING, TYPE_SERVER_BANDWIDTH, TYPE_SHARED_OBJECT, TYPE_STREAM_METADATA, TYPE_VIDEO_DATAFields inherited from interface org.red5.server.api.persistence.IPersistable
TRANSIENT_PREFIX -
Constructor Summary
ConstructorsConstructorDescriptionClientSharedObject(String name, boolean persistent) Create new client SO with -
Method Summary
Modifier and TypeMethodDescriptionvoidaddSharedObjectListener(ISharedObjectListener listener) Register object that will be notified about update events.booleanclear()Deletes all the attributes and sends a clear event to all listeners.voidclose()Detaches a reference from this shared object, reset it's state, this will destroy the reference immediately.voidconnect(IConnection conn) Connect the shared object using the passed connection.voidDisconnect the shared object.voidDispatches eventgetAttribute(String name, Object defaultValue) Return the value for a given attribute and set it if it doesn't exist.getServiceHandler(String name) Return a previously registered service handler.Get list of registered service handler names.booleanCheck if the shared object is connected to the server.protected voidNotify listeners on clearprotected voidNotify listeners on eventprotected voidnotifyDelete(String key) Notify listeners on attribute deleteprotected voidNotify listeners on disconnectprotected voidnotifySendMessage(String method, List<?> params) Broadcast send event to listenersprotected voidnotifyUpdate(String key, Object value) Notify listeners on updateprotected voidnotifyUpdate(String key, Map<String, Object> value) Notify listeners on map attribute updatevoidregisterServiceHandler(Object handler) Register an object that provides methods which handle calls without a service name to a shared object.voidregisterServiceHandler(String name, Object handler) Register an object that provides methods which can be called from a client.booleanremoveAttribute(String name) Remove an attribute.voidRemove all attributes.voidUnregister object to not longer receive update events.voidsendMessage(String handler, List<?> arguments) Broadcast event to event handlerbooleansetAttribute(String name, Object value) Set an attribute on this object.booleansetAttributes(Map<String, Object> values) Set multiple attributes on this object.booleansetAttributes(IAttributeStore values) Set multiple attributes on this object.voidUnregister the shared object handler for calls without a service name.Methods inherited from class org.red5.server.so.SharedObject
acquire, beginUpdate, beginUpdate, checkRelease, deserialize, endUpdate, getActiveListeners, getAttribute, getCreationTime, getData, getLastModified, getListeners, getMaxListeners, getName, getPath, getStore, getTotalChanges, getTotalDeletes, getTotalListeners, getTotalSends, getType, getVersion, isAcquired, isClosed, isPersistent, notifyModified, register, release, returnError, sendUpdates, serialize, setDirty, setDirty, setName, setPath, setPersistent, setStore, unregisterMethods inherited from class org.red5.server.AttributeStore
filterNull, from, getAttribute, getAttributeNames, getAttributes, getBoolAttribute, getByteAttribute, getDoubleAttribute, getIntAttribute, getListAttribute, getLongAttribute, getMapAttribute, getSetAttribute, getShortAttribute, getStringAttribute, hasAttribute, hasAttribute, removeAttribute, setAttribute, sizeMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface org.red5.server.api.IAttributeStore
getAttribute, getAttribute, getAttributeNames, getAttributes, hasAttribute, hasAttribute, removeAttribute, setAttribute, sizeMethods inherited from interface org.red5.server.api.ICastingAttributeStore
getBoolAttribute, getByteAttribute, getDoubleAttribute, getIntAttribute, getListAttribute, getLongAttribute, getMapAttribute, getSetAttribute, getShortAttribute, getStringAttributeMethods inherited from interface org.red5.server.api.so.ISharedObjectBase
beginUpdate, beginUpdate, endUpdate, getData, getVersion, isPersistent
-
Field Details
-
log
protected static org.slf4j.Logger log
-
-
Constructor Details
-
ClientSharedObject
Create new client SO with- Parameters:
name- Shared Object namepersistent- Persistence flag
-
-
Method Details
-
connect
Connect the shared object using the passed connection.- Specified by:
connectin interfaceIClientSharedObject- Parameters:
conn- Attach SO to given connection
-
disconnect
public void disconnect()Disconnect the shared object.- Specified by:
disconnectin interfaceIClientSharedObject
-
isConnected
public boolean isConnected()Check if the shared object is connected to the server.- Specified by:
isConnectedin interfaceIClientSharedObject- Returns:
- is connected
-
dispatchEvent
Dispatches event- Specified by:
dispatchEventin interfaceIEventDispatcher- Parameters:
e- Event object
-
notifyConnect
protected void notifyConnect()Notify listeners on event -
notifyDisconnect
protected void notifyDisconnect()Notify listeners on disconnect -
notifyUpdate
Notify listeners on update- Parameters:
key- Updated attribute keyvalue- Updated attribute value
-
notifyUpdate
Notify listeners on map attribute update- Parameters:
key- Updated attribute keyvalue- Updated attribute value
-
notifyDelete
Notify listeners on attribute delete- Parameters:
key- Attribute name
-
notifyClear
protected void notifyClear()Notify listeners on clear -
notifySendMessage
Broadcast send event to listeners- Parameters:
method- Method nameparams- Params
-
setAttribute
Set an attribute on this object.- Specified by:
setAttributein interfaceIAttributeStore- Overrides:
setAttributein classSharedObject- Parameters:
name- the name of the attribute to changevalue- the new value of the attribute- Returns:
- true if the attribute value was added or changed, otherwise false
-
setAttributes
Set multiple attributes on this object.- Specified by:
setAttributesin interfaceIAttributeStore- Overrides:
setAttributesin classSharedObject- Parameters:
values- the attributes to set- Returns:
- true if the attribute values changed otherwise false
-
setAttributes
Set multiple attributes on this object.- Specified by:
setAttributesin interfaceIAttributeStore- Overrides:
setAttributesin classSharedObject- Parameters:
values- the attributes to set- Returns:
- true if the attribute values changed otherwise false
-
removeAttribute
Remove an attribute.- Specified by:
removeAttributein interfaceAttributeStoreMXBean- Specified by:
removeAttributein interfaceIAttributeStore- Overrides:
removeAttributein classSharedObject- Parameters:
name- the name of the attribute to remove- Returns:
- true if the attribute was found and removed otherwise false
-
sendMessage
Broadcast event to event handler- Specified by:
sendMessagein interfaceISharedObjectBase- Overrides:
sendMessagein classSharedObject- Parameters:
handler- Event handlerarguments- Arguments
-
removeAttributes
public void removeAttributes()Remove all attributes.- Specified by:
removeAttributesin interfaceAttributeStoreMXBean- Specified by:
removeAttributesin interfaceIAttributeStore- Overrides:
removeAttributesin classSharedObject
-
clear
public boolean clear()Deletes all the attributes and sends a clear event to all listeners. The persistent data object is also removed from a persistent shared object.- Specified by:
clearin interfaceISharedObjectBase- Overrides:
clearin classSharedObject- Returns:
- true on success, false otherwise
-
close
public void close()Detaches a reference from this shared object, reset it's state, this will destroy the reference immediately. This is useful when you don't want to proxy a shared object any longer.- Specified by:
closein interfaceISharedObjectBase- Overrides:
closein classSharedObject
-
registerServiceHandler
Register an object that provides methods which handle calls without a service name to a shared object.- Specified by:
registerServiceHandlerin interfaceISharedObjectHandlerProvider- Parameters:
handler- the handler object
-
unregisterServiceHandler
Unregister the shared object handler for calls without a service name.- Specified by:
unregisterServiceHandlerin interfaceIServiceHandlerProvider- Specified by:
unregisterServiceHandlerin interfaceISharedObjectHandlerProvider- Parameters:
name- the name of the handler
-
registerServiceHandler
Register an object that provides methods which can be called from a client.
Example:
If you registered a handler with the name "one.two
" that provides a method "callMe
", you can call a method "one.two.callMe
" from the client.- Specified by:
registerServiceHandlerin interfaceIServiceHandlerProvider- Parameters:
name- the name of the handlerhandler- the handler object
-
getServiceHandler
Return a previously registered service handler.- Specified by:
getServiceHandlerin interfaceIServiceHandlerProvider- Parameters:
name- the name of the handler to return- Returns:
- the previously registered handler
-
getServiceHandlerNames
Get list of registered service handler names.- Specified by:
getServiceHandlerNamesin interfaceIServiceHandlerProvider- Returns:
- the names of the registered handlers
-
getAttribute
Return the value for a given attribute and set it if it doesn't exist. This is a utility function that internally performs the following code:
if (!hasAttribute(name)) setAttribute(name, defaultValue); return getAttribute(name);- Specified by:
getAttributein interfaceIAttributeStore- Overrides:
getAttributein classSharedObject- Parameters:
name- the name of the attribute to getdefaultValue- the value of the attribute to set if the attribute doesn't exist- Returns:
- the attribute value
-