## org.red5.server.api.so
Interface ISharedObjectBase

All Superinterfaces:
  AttributeStoreMBean, IAttributeStore, ICastingAttributeStore, IServiceHandlerProvider, ISharedObjectHandlerProvider

All Known Subinterfaces:
  IClientSharedObject, ISharedObject

All Known Implementing Classes:
  ClientSharedObject, SharedObjectScope

    public interface ISharedObjectBase

extends ISharedObjectHandlerProvider, ICastingAttributeStore

Base interface for shared objects. Changes to the shared objects are propagated to all subscribed clients. If you want to modify multiple attributes and notify the clients about all changes at once, you can use code like this:

`SharedObject.beginUpdate();
SharedObject.setAttribute("One", '1');
SharedObject.setAttribute("Two", '2');
SharedObject.removeAttribute("Three");
SharedObject.endUpdate();
`

All changes between "beginUpdate" and "endUpdate" will be sent to the clients using one notification event.

Author:
  The Red5 Project (red5@osflash.org), Joachim Bauch (jojo@struktur.de)

Method Summary
`void` `addSharedObjectListener(ISharedObjectListener listener)` Register object that will be notified about update events.
`void` `beginUpdate()` Start performing multiple updates to the shared object from serverside code.
`void` `beginUpdate(IEventListener source)` Start performing multiple updates to the shared object from a connected client.
`boolean` `clear()` Deletes all the attributes and sends a clear event to all listeners.
`void` `close()` Detaches a reference from this shared object, this will destroy the reference immediately.
`void` `endUpdate()` The multiple updates are complete, notify clients about all changes at once.
`Map<String,Object>` `getData()` Return a map containing all attributes of the shared object.
`int` `getVersion()` Returns the version of the shared object.
`boolean` `isLocked()` Returns the locked state of this SharedObject.
`boolean` `isPersistentObject()` Check if the object has been created as persistent shared object by the client.
`void` `lock()` Locks the shared object instance.
`void` `removeSharedObjectListener(ISharedObjectListener listener)` Unregister object to not longer receive update events.
`void` `sendMessage(String handler, List<?> arguments)` Send a message to a handler of the shared object.
`void` `unlock()` Unlocks a shared object instance that was locked with SharedObject.lock().

Methods inherited from interface org.red5.server.api.so.ISharedObjectHandlerProvider
`registerServiceHandler, unregisterServiceHandler`

Methods inherited from interface org.red5.server.api.service.IServiceHandlerProvider
`getServiceHandler, getServiceHandlerNames, registerServiceHandler`

Methods inherited from interface org.red5.server.api.ICastingAttributeStore
`getBoolAttribute, getByteAttribute, getDoubleAttribute, getIntAttribute, getListAttribute, getLongAttribute, getMapAttribute, getSetAttribute, getShortAttribute, getStringAttribute`

Methods inherited from interface org.red5.server.api.IAttributeStore
`getAttribute, getAttribute, getAttributeNames, getAttributes, hasAttribute, removeAttribute, removeAttributes, setAttribute, setAttributes, setAttributes`

Method Detail

### getVersion

    int getVersion()

  Returns the version of the shared object. The version is incremented automatically on each modification.

  Returns:
    the version of the shared object

### isPersistentObject

    boolean isPersistentObject()

  Check if the object has been created as persistent shared object by the client.

  Returns:
    true if the shared object is persistent, false otherwise

### getData

    Map<String,Object> getData()

  Return a map containing all attributes of the shared object.
  NOTE: The returned map will be read-only.

  Returns:
    a map containing all attributes of the shared object

### sendMessage

    void sendMessage(String handler,
                     List<?> arguments)

  Send a message to a handler of the shared object.

  Parameters:
    `handler` - the name of the handler to call
    `arguments` - a list of objects that should be passed as arguments to the handler

### beginUpdate

    void beginUpdate()

  Start performing multiple updates to the shared object from serverside code.

### beginUpdate

    void beginUpdate(IEventListener source)

  Start performing multiple updates to the shared object from a connected client.

  Parameters:
    `source` - Update events listener

### endUpdate

    void endUpdate()

  The multiple updates are complete, notify clients about all changes at once.

### addSharedObjectListener

    void addSharedObjectListener(ISharedObjectListener listener)

  Register object that will be notified about update events.

  Parameters:
    `listener` - the object to notify

### removeSharedObjectListener

    void removeSharedObjectListener(ISharedObjectListener listener)

  Unregister object to not longer receive update events.

  Parameters:
    `listener` - the object to unregister

### lock

    void lock()

  Locks the shared object instance. Prevents any changes to this object by clients until the SharedObject.unlock() method is called.

### unlock

    void unlock()

  Unlocks a shared object instance that was locked with SharedObject.lock().

### isLocked

    boolean isLocked()

  Returns the locked state of this SharedObject.

  Returns:
    true if in a locked state; false otherwise

### clear

    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.

  Returns:
    true if successful; false otherwise

### close

    void close()

  Detaches a reference from this shared object, this will destroy the reference immediately. This is useful when you don't want to proxy a shared object any longer.

Copyright © 2006-2010 The Red5 Project