## org.red5.server
Class Client

    java.lang.Object
      org.red5.server.AttributeStore
          org.red5.server.Client

All Implemented Interfaces:
  AttributeStoreMBean, ClientMBean, IAttributeStore, ICastingAttributeStore, IClient

    public class Client

extends AttributeStore
implements IClient

Client is an abstraction representing user connected to Red5 application. Clients are tied to connections and registred in ClientRegistry

Field Summary
`protected ConcurrentMap<IConnection,IScope>` `connToScope` Scopes this client connected to
`protected long` `creationTime` Creation time as Timestamp
`protected String` `id` Clients identifier
`protected static Logger` `log` Logger
`protected static String` `PERMISSIONS` Name of connection attribute holding the permissions.
`protected ClientRegistry` `registry` Client registry where Client is registered

Fields inherited from class org.red5.server.AttributeStore
`attributes`

Fields inherited from interface org.red5.server.api.IClient
`ID`

Constructor Summary
`Client()`
`Client(String id, ClientRegistry registry)` Creates client, sets creation time and registers it in ClientRegistry

Method Summary
`void` `disconnect()` Disconnects client from Red5 application
`boolean` `equals(Object obj)` Check clients equality by id
`Set<IConnection>` `getConnections()` Return set of connections for this client
`Set<IConnection>` `getConnections(IScope scope)` Return client connections to given scope
`long` `getCreationTime()` Get the creation time for this client object.
`String` `getId()` Returns the client id
`Collection<String>` `getPermissions(IConnection conn)` Return the permissions in a given context.
`Collection<IScope>` `getScopes()` Get a set of scopes the client is connected to.
`int` `hashCode()` if overriding equals then also do hashCode
`boolean` `hasPermission(IConnection conn, String permissionName)` Check if the client has a permission in the given context.
`List<String>` `iterateScopeNameList()` Iterate through the scopes and their attributes.
`protected void` `register(IConnection conn)` Associate connection with client
`void` `setId(String id)` Sets the clients id
`void` `setPermissions(IConnection conn, Collection<String> permissions)` Set the permissions for this client in a given context.
`String` `toString()`
`protected void` `unregister(IConnection conn)` Removes client-connection association for given connection

Methods inherited from class org.red5.server.AttributeStore
`filterNull, getAttribute, getAttribute, getAttributeNames, getAttributes, getBoolAttribute, getByteAttribute, getDoubleAttribute, getIntAttribute, getListAttribute, getLongAttribute, getMapAttribute, getSetAttribute, getShortAttribute, getStringAttribute, hasAttribute, removeAttribute, removeAttributes, setAttribute, setAttributes, setAttributes`

Methods inherited from class java.lang.Object
`clone, finalize, getClass, notify, notifyAll, wait, wait, wait`

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

Field Detail

### log

    protected static Logger log

  Logger

### PERMISSIONS

    protected static final String PERMISSIONS

  Name of connection attribute holding the permissions.

  See Also:
    Constant Field Values

### connToScope

    protected ConcurrentMap<IConnection,IScope> connToScope

  Scopes this client connected to

### creationTime

    protected long creationTime

  Creation time as Timestamp

### id

    protected String id

  Clients identifier

### registry

    protected ClientRegistry registry

  Client registry where Client is registered

Constructor Detail

### Client

    public Client()

### Client

    public Client(String id,
                  ClientRegistry registry)

  Creates client, sets creation time and registers it in ClientRegistry

  Parameters:
    `id` - Client id
    `registry` - ClientRegistry

Method Detail

### disconnect

    public void disconnect()

  Disconnects client from Red5 application

  Specified by:
    `disconnect` in interface `ClientMBean`
  Specified by:
    `disconnect` in interface `IClient`

### 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

### getConnections

    public Set<IConnection> getConnections()

  Return set of connections for this client

  Specified by:
    `getConnections` in interface `ClientMBean`
  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()

  Description copied from interface: `IClient`
  Get the creation time for this client object.

  Specified by:
    `getCreationTime` in interface `ClientMBean`
  Specified by:
    `getCreationTime` in interface `IClient`
  Returns:
    creation time

### setId

    public void setId(String id)

  Description copied from interface: `IClient`
  Sets the clients id

  Specified by:
    `setId` in interface `IClient`
  Parameters:
    `id` - client id

### getId

    public String getId()

  Returns the client id

  Specified by:
    `getId` in interface `ClientMBean`
  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 `ClientMBean`
  Specified by:
    `getScopes` in interface `IClient`
  Returns:
    scopes on this client

### hashCode

    public int hashCode()

  if overriding equals then also do hashCode

  Overrides:
    `hashCode` in class `Object`
  Returns:
    a has code

### iterateScopeNameList

    public List<String> iterateScopeNameList()

  Iterate through the scopes and their attributes. Used by JMX

  Returns:
    list of scope attributes

### register

    protected void register(IConnection conn)

  Associate connection with client

  Parameters:
    `conn` - Connection object

### toString

    public String toString()

  Overrides:
    `toString` in class `Object`
  Returns:
    string representation of client

### unregister

    protected void unregister(IConnection conn)

  Removes client-connection association for given connection

  Parameters:
    `conn` - Connection object

### 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.

Copyright © 2006-2010 The Red5 Project