Class Client

All Implemented Interfaces:
IAttributeStore, ICastingAttributeStore, IClient, AttributeStoreMXBean

public class Client extends AttributeStore implements IClient
Client is an abstraction representing user connected to Red5 application. Clients are tied to connections and registered in ClientRegistry
  • Field Details

    • log

      protected static org.slf4j.Logger log
    • PERMISSIONS

      protected static final String PERMISSIONS
      Name of connection attribute holding the permissions.
      See Also:
    • registry

      protected transient WeakReference<ClientRegistry> registry
      Client registry where Client is registered
    • connections

      protected transient CopyOnWriteArraySet<IConnection> connections
      Connections this client is associated with.
    • creationTime

      protected final long creationTime
      Creation time as Timestamp
    • id

      protected final String id
      Clients identifier
    • bandwidthChecked

      protected boolean bandwidthChecked
      Whether or not the bandwidth has been checked.
    • disconnected

      protected AtomicBoolean disconnected
      Disconnected state.
  • Constructor Details

    • Client

      @ConstructorProperties({"id","registry"}) public Client(String id, ClientRegistry registry)
      Creates client, sets creation time and registers it in ClientRegistry.
      Parameters:
      id - Client id
      registry - ClientRegistry
    • Client

      @ConstructorProperties({"id","creationTime","registry"}) public Client(String id, Long creationTime, ClientRegistry registry)
      Creates client, sets creation time and registers it in ClientRegistry.
      Parameters:
      id - Client id
      creationTime - Creation time
      registry - ClientRegistry
  • Method Details

    • disconnect

      public void disconnect()
      Disconnects client from Red5 application
      Specified by:
      disconnect in interface IClient
    • getConnections

      public Set<IConnection> getConnections()
      Return set of connections for this client
      Specified by:
      getConnections in interface IClient
      Returns:
      Set of connections
    • getConnections

      public Set<IConnection> getConnections(IScope scope)
      Return client connections to given scope
      Specified by:
      getConnections in interface IClient
      Parameters:
      scope - Scope
      Returns:
      Set of connections for that scope
    • getCreationTime

      public long getCreationTime()
      Returns the time at which the client was created.
      Specified by:
      getCreationTime in interface IClient
      Returns:
      creation time
    • getId

      public String getId()
      Returns the client id.
      Specified by:
      getId in interface IClient
      Returns:
      client id
    • getScopes

      public Collection<IScope> getScopes()
      Description copied from interface: IClient
      Get a set of scopes the client is connected to.
      Specified by:
      getScopes in interface IClient
      Returns:
      scopes on this client
    • iterateScopeNameList

      public List<String> iterateScopeNameList()
      Iterate through the scopes and their attributes. Used by JMX
      Returns:
      list of scope attributes
    • isRegistered

      public boolean isRegistered(IConnection conn)
      Returns registration status of given connection.
      Parameters:
      conn - connection
      Returns:
      true if registered and false otherwise
    • register

      protected void register(IConnection conn)
      Associate connection with client
      Parameters:
      conn - Connection object
    • unregister

      protected void unregister(IConnection conn)
      Removes client-connection association for given connection
      Parameters:
      conn - Connection object
    • unregister

      protected void unregister(IConnection conn, boolean deleteIfNoConns)
      Removes client-connection association for given connection
      Parameters:
      conn - Connection object
      deleteIfNoConns - Whether to delete this client if it no longer has any connections
    • isBandwidthChecked

      public boolean isBandwidthChecked()
      Returns whether or not a bandwidth check has been requested.
      Specified by:
      isBandwidthChecked in interface IClient
      Returns:
      true if requested and false otherwise
    • getPermissions

      public Collection<String> getPermissions(IConnection conn)
      Return the permissions in a given context.
      Specified by:
      getPermissions in interface IClient
      Parameters:
      conn - Connection specifying the context to get the permissions for.
      Returns:
      Permission names.
    • hasPermission

      public boolean hasPermission(IConnection conn, String permissionName)
      Check if the client has a permission in the given context.
      Specified by:
      hasPermission in interface IClient
      Parameters:
      conn - Connection specifying the context to check the permissions for
      permissionName - Name of the permission to check
      Returns:
       true
       
      if the client has the permission, otherwise
       false
       
    • setPermissions

      public void setPermissions(IConnection conn, Collection<String> permissions)
      Set the permissions for this client in a given context.
      Specified by:
      setPermissions in interface IClient
      Parameters:
      conn - Connection specifying the context to set the permissions for.
      permissions - Permissions the client has in this context or
       null
       
      for no permissions.
    • checkBandwidth

      public void checkBandwidth()
      Performs a bandwidth checking routine. Information may be found here: http://www.adobe.com/devnet/flashmediaserver/articles/dynamic_stream_switching_04.html
      Specified by:
      checkBandwidth in interface IClient
    • checkBandwidthUp

      public Map<String,Object> checkBandwidthUp(Object[] params)
      Performs a bandwidth checking callback for the client. Information may be found here: http://www.adobe.com/devnet/flashmediaserver/articles/dynamic_stream_switching_04.html
      Specified by:
      checkBandwidthUp in interface IClient
      Parameters:
      params - parameters
      Returns:
      bandwidth results
    • from

      public static Client from(CompositeData cd)
      Allows for reconstruction via CompositeData.
      Parameters:
      cd - composite data
      Returns:
      Client class instance
    • removeInstance

      private void removeInstance()
      Removes this instance from the client registry.
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object
    • equals

      public boolean equals(Object obj)
      Check clients equality by id
      Overrides:
      equals in class Object
      Parameters:
      obj - Object to check against
      Returns:
      true if clients ids are the same, false otherwise
    • toString

      public String toString()
      Overrides:
      toString in class Object
      Returns:
      string representation of client