org.red5.server
Class Client

java.lang.Object
  extended by org.red5.server.AttributeStore
      extended by org.red5.server.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 Summary
protected  boolean bandwidthChecked
          Whether or not the bandwidth has been checked.
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
           
protected static String PERMISSIONS
          Name of connection attribute holding the permissions.
protected  WeakReference<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(String id, ClientRegistry registry)
          Creates client, sets creation time and registers it in ClientRegistry DW: nope, does not currently register it in ClientRegistry!
 
Method Summary
 void checkBandwidth()
          Performs a bandwidth checking routine.
 Map<String,Object> checkBandwidthUp(Object[] params)
          Performs a bandwidth checking callback for the client.
 void disconnect()
          Disconnects client from Red5 application
 boolean equals(Object obj)
          Check clients equality by id
static Client from(CompositeData cd)
          Allows for reconstruction via CompositeData.
 Set<IConnection> getConnections()
          Return set of connections for this client
 Set<IConnection> getConnections(IScope scope)
          Return client connections to given scope
 long getCreationTime()
          Returns the time at which the client was created.
 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.
 boolean isBandwidthChecked()
          Returns whether or not a bandwidth check has been requested.
 List<String> iterateScopeNameList()
          Iterate through the scopes and their attributes.
protected  void register(IConnection conn)
          Associate connection with client
 void setCreationTime(long creationTime)
          Sets the time at which the client was created.
 void setId(String id)
          Sets the client 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
protected  void unregister(IConnection conn, boolean deleteIfNoConns)
          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, size
 
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, size
 

Field Detail

log

protected static Logger log

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 WeakReference<ClientRegistry> registry
Client registry where Client is registered


bandwidthChecked

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

Constructor Detail

Client

@ConstructorProperties(value={"id","registry"})
public Client(String id,
                                         ClientRegistry registry)
Creates client, sets creation time and registers it in ClientRegistry DW: nope, does not currently register 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 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

setCreationTime

public void setCreationTime(long creationTime)
Sets the time at which the client was created.

Parameters:
creationTime -

getCreationTime

public long getCreationTime()
Returns the time at which the client was created.

Specified by:
getCreationTime in interface IClient
Returns:
creation time

setId

public void setId(String id)
Sets the client id

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

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

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

from

public static Client from(CompositeData cd)
Allows for reconstruction via CompositeData.

Parameters:
cd - composite data
Returns:
Client class instance

hashCode

public int hashCode()
if overriding equals then also do hashCode

Overrides:
hashCode in class Object
Returns:
a has code

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


Copyright © 2006-2012 The Red5 Project