public class ClientSharedObject extends SharedObject implements IClientSharedObject, IEventDispatcher
Modifier and Type | Field and Description |
---|---|
protected static org.slf4j.Logger |
log
Logger
|
acquireCount, changeStats, deleteStats, lastModified, listenerStats, modified, name, ownerMessage, path, persistent, sendStats, source, storage, syncEvents, updateCounter, version
attributes
TRANSIENT_PREFIX
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_DATA
Constructor and Description |
---|
ClientSharedObject(String name,
boolean persistent)
Create new client SO with
|
Modifier and Type | Method and Description |
---|---|
void |
addSharedObjectListener(ISharedObjectListener listener)
Register object that will be notified about update events.
|
void |
beginUpdate()
Begin update of this Shared Object.
|
void |
beginUpdate(IEventListener listener)
Begin update of this Shared Object and setting listener
|
boolean |
clear()
Deletes all the attributes and sends a clear event to all listeners.
|
void |
close()
Detaches a reference from this shared object, reset it's state, this will destroy the
reference immediately.
|
void |
connect(IConnection conn)
Connect the shared object using the passed connection.
|
void |
disconnect()
Disconnect the shared object.
|
void |
dispatchEvent(IEvent e)
Dispatches event
|
void |
endUpdate()
End update of this Shared Object.
|
Object |
getAttribute(String name,
Object defaultValue)
Return attribute by name and set if it doesn't exist yet.
|
Object |
getServiceHandler(String name)
Return a previously registered service handler.
|
Set<String> |
getServiceHandlerNames()
Get list of registered service handler names.
|
boolean |
isConnected()
Check if the shared object is connected to the server.
|
boolean |
isLocked()
Returns the locked state of this SharedObject.
|
void |
lock()
Locks the shared object instance.
|
protected void |
notifyClear()
Notify listeners on clear
|
protected void |
notifyConnect()
Notify listeners on event
|
protected void |
notifyDelete(String key)
Notify listeners on attribute delete
|
protected void |
notifyDisconnect()
Notify listeners on disconnect
|
protected void |
notifySendMessage(String method,
List<?> params)
Broadcast send event to listeners
|
protected void |
notifyUpdate(String key,
Map<String,Object> value)
Notify listeners on map attribute update
|
protected void |
notifyUpdate(String key,
Object value)
Notify listeners on update
|
void |
registerServiceHandler(Object handler)
Register an object that provides methods which handle calls without
a service name to a shared object.
|
void |
registerServiceHandler(String name,
Object handler)
Register an object that provides methods which can be called from a
client.
|
boolean |
removeAttribute(String name)
Removes attribute with given name
|
void |
removeAttributes()
Remove all attributes (clear Shared Object)
|
void |
removeSharedObjectListener(ISharedObjectListener listener)
Unregister object to not longer receive update events.
|
void |
sendMessage(String handler,
List<?> arguments)
Broadcast event to event handler
|
boolean |
setAttribute(String name,
Object value)
Set value of attribute with given name
|
void |
setAttributes(IAttributeStore values)
Set attributes as attributes store.
|
void |
setAttributes(Map<String,Object> values)
Set attributes as map.
|
void |
unlock()
Unlocks a shared object instance that was locked with
SharedObject.lock().
|
void |
unregisterServiceHandler(String name)
Unregister the shared object handler for calls without a service name.
|
acquire, checkRelease, deserialize, getActiveListeners, getCreationTime, getData, getLastModified, getListeners, getMaxListeners, getName, getPath, getStore, getTotalChanges, getTotalDeletes, getTotalListeners, getTotalSends, getType, getVersion, isAcquired, isPersistent, notifyModified, register, release, returnAttributeValue, returnError, sendUpdates, serialize, setName, setPath, setPersistent, setStore, unregister
filterNull, from, getAttribute, getAttributeNames, getAttributes, getBoolAttribute, getByteAttribute, getDoubleAttribute, getIntAttribute, getListAttribute, getLongAttribute, getMapAttribute, getSetAttribute, getShortAttribute, getStringAttribute, hasAttribute
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
getData, getVersion, isPersistent
getBoolAttribute, getByteAttribute, getDoubleAttribute, getIntAttribute, getListAttribute, getLongAttribute, getMapAttribute, getSetAttribute, getShortAttribute, getStringAttribute
getAttribute, getAttributeNames, getAttributes, hasAttribute
public ClientSharedObject(String name, boolean persistent)
name
- Shared Object namepersistent
- Persistence flagpublic void connect(IConnection conn)
connect
in interface IClientSharedObject
conn
- Attach SO to given connectionpublic void disconnect()
disconnect
in interface IClientSharedObject
public boolean isConnected()
isConnected
in interface IClientSharedObject
public void addSharedObjectListener(ISharedObjectListener listener)
addSharedObjectListener
in interface ISharedObjectBase
listener
- the object to notifypublic void removeSharedObjectListener(ISharedObjectListener listener)
removeSharedObjectListener
in interface ISharedObjectBase
listener
- the object to unregisterpublic void dispatchEvent(IEvent e)
dispatchEvent
in interface IEventDispatcher
e
- Event objectprotected void notifyConnect()
protected void notifyDisconnect()
protected void notifyUpdate(String key, Object value)
key
- Updated attribute keyvalue
- Updated attribute valueprotected void notifyUpdate(String key, Map<String,Object> value)
key
- Updated attribute keyvalue
- Updated attribute valueprotected void notifyDelete(String key)
key
- Attribute nameprotected void notifyClear()
protected void notifySendMessage(String method, List<?> params)
method
- Method nameparams
- Paramspublic boolean setAttribute(String name, Object value)
setAttribute
in interface IAttributeStore
setAttribute
in class SharedObject
name
- Attribute namevalue
- Attribute valuetrue
if there's such attribute and value was set, false
otherwisepublic void setAttributes(IAttributeStore values)
setAttributes
in interface IAttributeStore
setAttributes
in class SharedObject
values
- Attributes.public void setAttributes(Map<String,Object> values)
setAttributes
in interface IAttributeStore
setAttributes
in class SharedObject
values
- Attributes.public boolean removeAttribute(String name)
removeAttribute
in interface IAttributeStore
removeAttribute
in interface AttributeStoreMXBean
removeAttribute
in class SharedObject
name
- Attributetrue
if there's such an attribute and it was removed, false
otherwisepublic void sendMessage(String handler, List<?> arguments)
sendMessage
in interface ISharedObjectBase
sendMessage
in class SharedObject
handler
- Event handlerarguments
- Argumentspublic void removeAttributes()
removeAttributes
in interface IAttributeStore
removeAttributes
in interface AttributeStoreMXBean
removeAttributes
in class SharedObject
public boolean clear()
clear
in interface ISharedObjectBase
clear
in class SharedObject
true
on success, false
otherwisepublic void close()
close
in interface ISharedObjectBase
close
in class SharedObject
public void beginUpdate()
beginUpdate
in interface ISharedObjectBase
beginUpdate
in class SharedObject
public void beginUpdate(IEventListener listener)
beginUpdate
in interface ISharedObjectBase
beginUpdate
in class SharedObject
listener
- Update with listenerpublic void endUpdate()
endUpdate
in interface ISharedObjectBase
endUpdate
in class SharedObject
public void lock()
lock
in interface ISharedObjectBase
public void unlock()
unlock
in interface ISharedObjectBase
public boolean isLocked()
isLocked
in interface ISharedObjectBase
public void registerServiceHandler(Object handler)
registerServiceHandler
in interface ISharedObjectHandlerProvider
handler
- the handler objectpublic void unregisterServiceHandler(String name)
unregisterServiceHandler
in interface IServiceHandlerProvider
unregisterServiceHandler
in interface ISharedObjectHandlerProvider
name
- the name of the handlerpublic void registerServiceHandler(String name, Object handler)
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.
registerServiceHandler
in interface IServiceHandlerProvider
name
- the name of the handlerhandler
- the handler objectpublic Object getServiceHandler(String name)
getServiceHandler
in interface IServiceHandlerProvider
name
- the name of the handler to returnpublic Set<String> getServiceHandlerNames()
getServiceHandlerNames
in interface IServiceHandlerProvider
public Object getAttribute(String name, Object defaultValue)
getAttribute
in interface IAttributeStore
getAttribute
in class SharedObject
name
- Attribute namedefaultValue
- Value to set if attribute doesn't existCopyright © 2006-2012 The Red5 Project