Package com.wowza.wms.sharedobject
Class SharedObject
- Object
-
- com.wowza.wms.sharedobject.SharedObject
-
- All Implemented Interfaces:
ISharedObject
public class SharedObject extends Object implements ISharedObject
-
-
Field Summary
Fields Modifier and Type Field Description static int
READACCESS
static int
WRITEACCESS
-
Fields inherited from interface com.wowza.wms.sharedobject.ISharedObject
FILEEXTENSION, SHAREDOBJECT_CMD_CONNECT, SHAREDOBJECT_CMD_CONNECTSUCCESS, SHAREDOBJECT_CMD_DELETE, SHAREDOBJECT_CMD_DISCONNECT, SHAREDOBJECT_CMD_ERROR, SHAREDOBJECT_CMD_SEND, SHAREDOBJECT_CMD_SETVALUE, SHAREDOBJECT_STATUS_CHANGE, SHAREDOBJECT_STATUS_CLEAR, SHAREDOBJECT_STATUS_DELETE, SHAREDOBJECT_STATUS_SUCCESS
-
-
Constructor Summary
Constructors Constructor Description SharedObject(String name)
Create new shared objectSharedObject(String name, boolean isPersistent, String storageDir)
Create new shared object
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description void
acquire()
Increment the reference count to this shared object.void
addClient(IClient client)
Add a client to this shared object.void
addSlotListener(ISharedObjectSlotNotify slotListener)
Add a slot listener.void
clear()
Clear all properties from a shared objectvoid
close()
Force close this shared object (not implemented)boolean
containsProperty(String slotName)
Returns true is slot/property name existsboolean
containsSlot(String slotName)
Returns true is slot/property name existsvoid
deleteSlot(IClient client, String slotName)
Remove a slot (property)void
deleteSlot(String slotName)
Remove slot (property)void
disconnect(IClient client)
Disconnect client from shared object.void
flush()
Flush (write to disk) shared objectstatic boolean[]
getAccess(IClient client, String soName)
java.util.List<com.wowza.wms.sharedobject.SharedObjectClient>
getClients()
Get a list of client that are connected to this shared object.void
getClientUpdates(IClient client)
String
getName()
Get shared object nameISharedObjects
getParent()
Get the shared object container to which this shared object belongs.AMFData
getProperty(String slotName)
Get slot (property) value.int
getRefCount()
Get the current reference (clients) connected to this shared object.ISharedObjectSlot
getSlot(String name)
Get ISharedObjectSlot interface to a slot (property) by namejava.util.List<String>
getSlotNames()
Get a list of slot (property) namesjava.util.List<ISharedObjectSlot>
getSlots()
Get a list of active slotsString
getStorageDir()
Get path used to store shared object.int
getVersion()
Get the internval version number.boolean
isClient(IClient client)
Is this client connected to shared objectboolean
isPersistent()
Is this shared object being persisted.void
load()
void
lock()
Lock a shared object for write accessvoid
notifySlotDelete(ISharedObjectSlot slot)
void
notifySlotSetValue(ISharedObjectSlot slot)
int
purge(int version)
Purge all deleted properties older than the version numbervoid
putSlot(String name, ISharedObjectSlot slot)
Add a new slot (property) to a shared object.void
release()
Descrement the reference count to this shared object.void
removeClient(IClient client)
Remove a client from this shared object.void
removeSlotListener(ISharedObjectSlotNotify slotListener)
Remove slot listenervoid
send(String handlerName)
Call client side handler attached to shared object (no parameters).void
send(String handlerName, Object... params)
Call client side handler attached to shared object.void
sendInternal(IClient client, String handlerName, byte[] msgBytes)
void
sendInternal(IClient client, String handlerName, byte[] msgBytes, AMFDataContextDeserialize context)
void
sendInternal(String handlerName, AMFData[] params)
void
setName(String name)
Set shared object namevoid
setParent(ISharedObjects parent)
void
setPersistent(boolean isPersistent)
Set is shared object persisted.void
setProperty(String slotName, boolean value)
Set slot (property) value as a boolean value (will be wrapped in an AMFDataItem object)void
setProperty(String slotName, double value)
Set slot (property) value as a double value (will be wrapped in an AMFDataItem object)void
setProperty(String slotName, int value)
Set slot (property) value as a int value (will be wrapped in an AMFDataItem object)void
setProperty(String slotName, long value)
Set slot (property) value as a long value (will be wrapped in an AMFDataItem object)void
setProperty(String slotName, AMFData data)
Set slot (property) value as AMFData object.void
setProperty(String slotName, String value)
Set slot (property) value as a string value (will be wrapped in an AMFDataItem object)void
setProperty(String slotName, java.util.Date value)
Set slot (property) value as a date value (will be wrapped in an AMFDataItem object)void
setSlotValue(IClient client, String slotName, byte[] byteData)
void
setSlotValue(IClient client, String slotName, byte[] byteData, AMFData amfData)
void
setSlotValue(IClient client, String slotName, byte[] byteData, AMFDataContextDeserialize context)
void
setSlotValue(IClient client, String slotName, byte[] byteData, AMFData amfData, AMFDataContextDeserialize context)
void
setSlotValue(IClient client, String slotName, AMFData amfData)
void
setStorageDir(String storageDir)
Set path used to store shared object.void
setVersion(int version)
Set the internal version number.int
size()
Get the number of active slot (properties).void
unlock()
Unlock a shared object for write accessvoid
writeDeleteError(IClient client, String soName, boolean isPersistent, String slotName, String errorMsg)
Write an delete error message back to the clientstatic void
writeError(IClient client, String soName, boolean isPersistent, String errorMsg, boolean isConnect)
void
writeSetValueError(IClient client, String soName, boolean isPersistent, String slotName, String errorMsg)
Write an set value error message back to the client
-
-
-
Field Detail
-
READACCESS
public static final int READACCESS
- See Also:
- Constant Field Values
-
WRITEACCESS
public static final int WRITEACCESS
- See Also:
- Constant Field Values
-
-
Constructor Detail
-
SharedObject
public SharedObject(String name)
Create new shared object- Parameters:
name
- shared object name
-
SharedObject
public SharedObject(String name, boolean isPersistent, String storageDir)
Create new shared object- Parameters:
name
- shared object nameisPersistent
- is persistentstorageDir
- storage directory for persistent shared object
-
-
Method Detail
-
size
public int size()
Description copied from interface:ISharedObject
Get the number of active slot (properties). Deleted slots are not counted.- Specified by:
size
in interfaceISharedObject
- Returns:
- number of active slot (properties). Deleted slots are not counted
-
purge
public int purge(int version)
Description copied from interface:ISharedObject
Purge all deleted properties older than the version number- Specified by:
purge
in interfaceISharedObject
- Returns:
- number of slots purged
-
clear
public void clear()
Description copied from interface:ISharedObject
Clear all properties from a shared object- Specified by:
clear
in interfaceISharedObject
-
getSlots
public java.util.List<ISharedObjectSlot> getSlots()
Description copied from interface:ISharedObject
Get a list of active slots- Specified by:
getSlots
in interfaceISharedObject
- Returns:
- list of active slots
-
getSlotNames
public java.util.List<String> getSlotNames()
Description copied from interface:ISharedObject
Get a list of slot (property) names- Specified by:
getSlotNames
in interfaceISharedObject
- Returns:
- list of slot (property) names
-
getSlot
public ISharedObjectSlot getSlot(String name)
Description copied from interface:ISharedObject
Get ISharedObjectSlot interface to a slot (property) by name- Specified by:
getSlot
in interfaceISharedObject
- Parameters:
name
- slot (property) name- Returns:
- ISharedObjectSlot interface
-
putSlot
public void putSlot(String name, ISharedObjectSlot slot)
Description copied from interface:ISharedObject
Add a new slot (property) to a shared object.- Specified by:
putSlot
in interfaceISharedObject
- Parameters:
name
- slot (property) nameslot
- new slot
-
getClients
public java.util.List<com.wowza.wms.sharedobject.SharedObjectClient> getClients()
Description copied from interface:ISharedObject
Get a list of client that are connected to this shared object.- Specified by:
getClients
in interfaceISharedObject
- Returns:
- list of client that are connected to this shared object
-
isClient
public boolean isClient(IClient client)
Description copied from interface:ISharedObject
Is this client connected to shared object- Specified by:
isClient
in interfaceISharedObject
- Parameters:
client
- client- Returns:
- true if client is conencted to shared object
-
addClient
public void addClient(IClient client)
Description copied from interface:ISharedObject
Add a client to this shared object.- Specified by:
addClient
in interfaceISharedObject
- Parameters:
client
- client
-
removeClient
public void removeClient(IClient client)
Description copied from interface:ISharedObject
Remove a client from this shared object.- Specified by:
removeClient
in interfaceISharedObject
- Parameters:
client
- client
-
acquire
public void acquire()
Description copied from interface:ISharedObject
Increment the reference count to this shared object.- Specified by:
acquire
in interfaceISharedObject
-
release
public void release()
Description copied from interface:ISharedObject
Descrement the reference count to this shared object.- Specified by:
release
in interfaceISharedObject
-
getRefCount
public int getRefCount()
Description copied from interface:ISharedObject
Get the current reference (clients) connected to this shared object. Includes unbalanced count of calls to acquire.- Specified by:
getRefCount
in interfaceISharedObject
- Returns:
- the current reference (clients) connected to this shared object
-
isPersistent
public boolean isPersistent()
Description copied from interface:ISharedObject
Is this shared object being persisted.- Specified by:
isPersistent
in interfaceISharedObject
- Returns:
- true if shared object is being persisted
-
setPersistent
public void setPersistent(boolean isPersistent)
Description copied from interface:ISharedObject
Set is shared object persisted.- Specified by:
setPersistent
in interfaceISharedObject
- Parameters:
isPersistent
- true if shared object is being persisted
-
getVersion
public int getVersion()
Description copied from interface:ISharedObject
Get the internval version number.- Specified by:
getVersion
in interfaceISharedObject
- Returns:
- internval version number
-
setVersion
public void setVersion(int version)
Description copied from interface:ISharedObject
Set the internal version number.- Specified by:
setVersion
in interfaceISharedObject
- Parameters:
version
- internal version number
-
deleteSlot
public void deleteSlot(String slotName)
Description copied from interface:ISharedObject
Remove slot (property)- Specified by:
deleteSlot
in interfaceISharedObject
- Parameters:
slotName
- slot (property) name
-
containsProperty
public boolean containsProperty(String slotName)
Description copied from interface:ISharedObject
Returns true is slot/property name exists- Specified by:
containsProperty
in interfaceISharedObject
- Parameters:
slotName
- slot/property name- Returns:
- true is slot/property name exists
-
containsSlot
public boolean containsSlot(String slotName)
Description copied from interface:ISharedObject
Returns true is slot/property name exists- Specified by:
containsSlot
in interfaceISharedObject
- Parameters:
slotName
- slot/property name- Returns:
- true is slot/property name exists
-
deleteSlot
public void deleteSlot(IClient client, String slotName)
Description copied from interface:ISharedObject
Remove a slot (property)- Specified by:
deleteSlot
in interfaceISharedObject
- Parameters:
client
- client removing slot or null if server side codeslotName
- slot (property) name
-
getProperty
public AMFData getProperty(String slotName)
Description copied from interface:ISharedObject
Get slot (property) value.- Specified by:
getProperty
in interfaceISharedObject
- Parameters:
slotName
- slot (property) name- Returns:
- slot (property) value as AMFData object
-
setProperty
public void setProperty(String slotName, boolean value)
Description copied from interface:ISharedObject
Set slot (property) value as a boolean value (will be wrapped in an AMFDataItem object)- Specified by:
setProperty
in interfaceISharedObject
- Parameters:
slotName
- slot (property) namevalue
- boolean value
-
setProperty
public void setProperty(String slotName, java.util.Date value)
Description copied from interface:ISharedObject
Set slot (property) value as a date value (will be wrapped in an AMFDataItem object)- Specified by:
setProperty
in interfaceISharedObject
- Parameters:
slotName
- slot (property) namevalue
- date value
-
setProperty
public void setProperty(String slotName, double value)
Description copied from interface:ISharedObject
Set slot (property) value as a double value (will be wrapped in an AMFDataItem object)- Specified by:
setProperty
in interfaceISharedObject
- Parameters:
slotName
- slot (property) namevalue
- double value
-
setProperty
public void setProperty(String slotName, long value)
Description copied from interface:ISharedObject
Set slot (property) value as a long value (will be wrapped in an AMFDataItem object)- Specified by:
setProperty
in interfaceISharedObject
- Parameters:
slotName
- slot (property) namevalue
- long value
-
setProperty
public void setProperty(String slotName, int value)
Description copied from interface:ISharedObject
Set slot (property) value as a int value (will be wrapped in an AMFDataItem object)- Specified by:
setProperty
in interfaceISharedObject
- Parameters:
slotName
- slot (property) namevalue
- int value
-
setProperty
public void setProperty(String slotName, String value)
Description copied from interface:ISharedObject
Set slot (property) value as a string value (will be wrapped in an AMFDataItem object)- Specified by:
setProperty
in interfaceISharedObject
- Parameters:
slotName
- slot (property) namevalue
- string value
-
setProperty
public void setProperty(String slotName, AMFData data)
Description copied from interface:ISharedObject
Set slot (property) value as AMFData object.- Specified by:
setProperty
in interfaceISharedObject
- Parameters:
slotName
- slot (property) namedata
- slot value as AMFData object. Example: new AMFDataItem((double)1.234) or new AMFDataItem()
-
setSlotValue
public void setSlotValue(IClient client, String slotName, byte[] byteData)
-
setSlotValue
public void setSlotValue(IClient client, String slotName, byte[] byteData, AMFDataContextDeserialize context)
-
setSlotValue
public void setSlotValue(IClient client, String slotName, byte[] byteData, AMFData amfData)
-
setSlotValue
public void setSlotValue(IClient client, String slotName, byte[] byteData, AMFData amfData, AMFDataContextDeserialize context)
-
writeError
public static void writeError(IClient client, String soName, boolean isPersistent, String errorMsg, boolean isConnect)
-
writeSetValueError
public void writeSetValueError(IClient client, String soName, boolean isPersistent, String slotName, String errorMsg)
Description copied from interface:ISharedObject
Write an set value error message back to the client- Specified by:
writeSetValueError
in interfaceISharedObject
- Parameters:
client
- client removing slot or null if server side codesoName
- sharedObject nameisPersistent
- is persistentslotName
- slot nameerrorMsg
- error message
-
writeDeleteError
public void writeDeleteError(IClient client, String soName, boolean isPersistent, String slotName, String errorMsg)
Description copied from interface:ISharedObject
Write an delete error message back to the client- Specified by:
writeDeleteError
in interfaceISharedObject
- Parameters:
client
- client removing slot or null if server side codesoName
- sharedObject nameisPersistent
- is persistentslotName
- slot nameerrorMsg
- error message
-
getClientUpdates
public void getClientUpdates(IClient client)
-
disconnect
public void disconnect(IClient client)
Description copied from interface:ISharedObject
Disconnect client from shared object.- Specified by:
disconnect
in interfaceISharedObject
- Parameters:
client
- client to disconnect
-
getName
public String getName()
Description copied from interface:ISharedObject
Get shared object name- Specified by:
getName
in interfaceISharedObject
- Returns:
- shared object name
-
setName
public void setName(String name)
Description copied from interface:ISharedObject
Set shared object name- Specified by:
setName
in interfaceISharedObject
- Parameters:
name
- shared object name
-
send
public void send(String handlerName, Object... params)
Description copied from interface:ISharedObject
Call client side handler attached to shared object.- Specified by:
send
in interfaceISharedObject
- Parameters:
handlerName
- handler nameparams
- variable argument list of parameters
-
send
public void send(String handlerName)
Description copied from interface:ISharedObject
Call client side handler attached to shared object (no parameters).- Specified by:
send
in interfaceISharedObject
- Parameters:
handlerName
- handler name
-
sendInternal
public void sendInternal(String handlerName, AMFData[] params)
-
sendInternal
public void sendInternal(IClient client, String handlerName, byte[] msgBytes)
-
sendInternal
public void sendInternal(IClient client, String handlerName, byte[] msgBytes, AMFDataContextDeserialize context)
-
addSlotListener
public void addSlotListener(ISharedObjectSlotNotify slotListener)
Description copied from interface:ISharedObject
Add a slot listener. Will receive the following events: onSlotSetValue and onSlotDelete- Specified by:
addSlotListener
in interfaceISharedObject
- Parameters:
slotListener
- slot listener
-
removeSlotListener
public void removeSlotListener(ISharedObjectSlotNotify slotListener)
Description copied from interface:ISharedObject
Remove slot listener- Specified by:
removeSlotListener
in interfaceISharedObject
- Parameters:
slotListener
- slot listener
-
notifySlotSetValue
public void notifySlotSetValue(ISharedObjectSlot slot)
-
notifySlotDelete
public void notifySlotDelete(ISharedObjectSlot slot)
-
getStorageDir
public String getStorageDir()
Description copied from interface:ISharedObject
Get path used to store shared object.- Specified by:
getStorageDir
in interfaceISharedObject
- Returns:
- path used to store shared object
-
setStorageDir
public void setStorageDir(String storageDir)
Description copied from interface:ISharedObject
Set path used to store shared object.- Specified by:
setStorageDir
in interfaceISharedObject
- Parameters:
storageDir
- path used to store shared object
-
flush
public void flush()
Description copied from interface:ISharedObject
Flush (write to disk) shared object- Specified by:
flush
in interfaceISharedObject
-
load
public void load()
-
close
public void close()
Description copied from interface:ISharedObject
Force close this shared object (not implemented)- Specified by:
close
in interfaceISharedObject
-
lock
public void lock()
Description copied from interface:ISharedObject
Lock a shared object for write access- Specified by:
lock
in interfaceISharedObject
-
unlock
public void unlock()
Description copied from interface:ISharedObject
Unlock a shared object for write access- Specified by:
unlock
in interfaceISharedObject
-
setParent
public void setParent(ISharedObjects parent)
-
getParent
public ISharedObjects getParent()
Description copied from interface:ISharedObject
Get the shared object container to which this shared object belongs.- Specified by:
getParent
in interfaceISharedObject
- Returns:
- shared object container
-
getAccess
public static boolean[] getAccess(IClient client, String soName)
-
-