Class SharedObject

Object
com.wowza.wms.sharedobject.SharedObject
All Implemented Interfaces:
ISharedObject

public class SharedObject extends Object implements ISharedObject
  • Field Details

  • Constructor Details

    • 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 name
      isPersistent - is persistent
      storageDir - storage directory for persistent shared object
  • Method Details

    • 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 interface ISharedObject
      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 interface ISharedObject
      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 interface ISharedObject
    • getSlots

      public List<ISharedObjectSlot> getSlots()
      Description copied from interface: ISharedObject
      Get a list of active slots
      Specified by:
      getSlots in interface ISharedObject
      Returns:
      list of active slots
    • getSlotNames

      public List<String> getSlotNames()
      Description copied from interface: ISharedObject
      Get a list of slot (property) names
      Specified by:
      getSlotNames in interface ISharedObject
      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 interface ISharedObject
      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 interface ISharedObject
      Parameters:
      name - slot (property) name
      slot - new slot
    • getClients

      public 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 interface ISharedObject
      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 interface ISharedObject
      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 interface ISharedObject
      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 interface ISharedObject
      Parameters:
      client - client
    • acquire

      public void acquire()
      Description copied from interface: ISharedObject
      Increment the reference count to this shared object.
      Specified by:
      acquire in interface ISharedObject
    • release

      public void release()
      Description copied from interface: ISharedObject
      Descrement the reference count to this shared object.
      Specified by:
      release in interface ISharedObject
    • 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 interface ISharedObject
      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 interface ISharedObject
      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 interface ISharedObject
      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 interface ISharedObject
      Returns:
      internval version number
    • setVersion

      public void setVersion(int version)
      Description copied from interface: ISharedObject
      Set the internal version number.
      Specified by:
      setVersion in interface ISharedObject
      Parameters:
      version - internal version number
    • deleteSlot

      public void deleteSlot(String slotName)
      Description copied from interface: ISharedObject
      Remove slot (property)
      Specified by:
      deleteSlot in interface ISharedObject
      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 interface ISharedObject
      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 interface ISharedObject
      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 interface ISharedObject
      Parameters:
      client - client removing slot or null if server side code
      slotName - slot (property) name
    • getProperty

      public AMFData getProperty(String slotName)
      Description copied from interface: ISharedObject
      Get slot (property) value.
      Specified by:
      getProperty in interface ISharedObject
      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 interface ISharedObject
      Parameters:
      slotName - slot (property) name
      value - boolean value
    • setProperty

      public void setProperty(String slotName, 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 interface ISharedObject
      Parameters:
      slotName - slot (property) name
      value - 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 interface ISharedObject
      Parameters:
      slotName - slot (property) name
      value - 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 interface ISharedObject
      Parameters:
      slotName - slot (property) name
      value - 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 interface ISharedObject
      Parameters:
      slotName - slot (property) name
      value - 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 interface ISharedObject
      Parameters:
      slotName - slot (property) name
      value - 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 interface ISharedObject
      Parameters:
      slotName - slot (property) name
      data - slot value as AMFData object. Example: new AMFDataItem((double)1.234) or new AMFDataItem()
    • setSlotValue

      public void setSlotValue(IClient client, String slotName, AMFData amfData)
    • 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 interface ISharedObject
      Parameters:
      client - client removing slot or null if server side code
      soName - sharedObject name
      isPersistent - is persistent
      slotName - slot name
      errorMsg - 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 interface ISharedObject
      Parameters:
      client - client removing slot or null if server side code
      soName - sharedObject name
      isPersistent - is persistent
      slotName - slot name
      errorMsg - 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 interface ISharedObject
      Parameters:
      client - client to disconnect
    • getName

      public String getName()
      Description copied from interface: ISharedObject
      Get shared object name
      Specified by:
      getName in interface ISharedObject
      Returns:
      shared object name
    • setName

      public void setName(String name)
      Description copied from interface: ISharedObject
      Set shared object name
      Specified by:
      setName in interface ISharedObject
      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 interface ISharedObject
      Parameters:
      handlerName - handler name
      params - 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 interface ISharedObject
      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 interface ISharedObject
      Parameters:
      slotListener - slot listener
    • removeSlotListener

      public void removeSlotListener(ISharedObjectSlotNotify slotListener)
      Description copied from interface: ISharedObject
      Remove slot listener
      Specified by:
      removeSlotListener in interface ISharedObject
      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 interface ISharedObject
      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 interface ISharedObject
      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 interface ISharedObject
    • load

      public void load()
    • close

      public void close()
      Description copied from interface: ISharedObject
      Force close this shared object (not implemented)
      Specified by:
      close in interface ISharedObject
    • lock

      public void lock()
      Description copied from interface: ISharedObject
      Lock a shared object for write access
      Specified by:
      lock in interface ISharedObject
    • unlock

      public void unlock()
      Description copied from interface: ISharedObject
      Unlock a shared object for write access
      Specified by:
      unlock in interface ISharedObject
    • 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 interface ISharedObject
      Returns:
      shared object container
    • getAccess

      public static boolean[] getAccess(IClient client, String soName)