|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.red5.server.net.remoting.RemotingConnection
public class RemotingConnection
Connection class so the Red5 object works in methods invoked through remoting. Attributes are stored in the session of the implementing servlet container.
Nested Class Summary |
---|
Nested classes/interfaces inherited from interface org.red5.server.api.IConnection |
---|
IConnection.Encoding |
Field Summary | |
---|---|
protected CopyOnWriteArrayList<IConnectionListener> |
connectionListeners
Listeners |
protected List<IRemotingHeader> |
headers
Headers to be returned to the client. |
protected RemotingPacket |
packet
Remoting packet that triggered the connection. |
protected javax.servlet.http.HttpServletRequest |
request
Servlet request |
protected IScope |
scope
Scope |
protected javax.servlet.http.HttpSession |
session
Session used to store properties. |
Fields inherited from interface org.red5.server.api.IConnection |
---|
PERSISTENT, POLLING, TRANSIENT |
Constructor Summary | |
---|---|
RemotingConnection(javax.servlet.http.HttpServletRequest request,
IScope scope,
RemotingPacket packet)
Create servlet connection from request and scope. |
Method Summary | |
---|---|
void |
addHeader(String name,
Object value)
Tell the client to add a header with all further requests. |
void |
addHeader(String name,
Object value,
boolean mustUnderstand)
Tell the client to add a header with all further requests. |
void |
addListener(IConnectionListener listener)
Adds a listener to this object |
void |
cleanup()
Cleans up the remoting connection client from the HttpSession and client registry. |
void |
close()
Close this connection. |
boolean |
connect(IScope scope)
Try to connect to the scope. |
boolean |
connect(IScope scope,
Object[] params)
Try to connect to the scope with a list of connection parameters. |
void |
dispatchEvent(IEvent event)
Dispatches event |
void |
dispatchEvent(Object event)
|
Object |
getAttribute(String name)
Return the value for a given attribute. |
Object |
getAttribute(String name,
Object defaultValue)
Return the value for a given attribute and set it if it doesn't exist. |
Set<String> |
getAttributeNames()
Get the attribute names. |
Map<String,Object> |
getAttributes()
Get the attributes. |
Iterator<IBasicScope> |
getBasicScopes()
Get the basic scopes this connection has subscribed. |
Boolean |
getBoolAttribute(String name)
Get Boolean attribute by name |
Byte |
getByteAttribute(String name)
Get Byte attribute by name |
IClient |
getClient()
Get the client object associated with this connection. |
long |
getClientBytesRead()
Return number of written bytes the client reports to have received. |
Map<String,Object> |
getConnectParams()
Return the parameters that were given in the call to "connect". |
Double |
getDoubleAttribute(String name)
Get Double attribute by name |
long |
getDroppedMessages()
Total number of messages that have been dropped. |
IConnection.Encoding |
getEncoding()
Return encoding (AMF0 or AMF3). |
Collection<IRemotingHeader> |
getHeaders()
Return headers to send. |
String |
getHost()
Get the hostname that the client is connected to. |
Integer |
getIntAttribute(String name)
Get Integer attribute by name |
int |
getLastPingTime()
Return roundtrip time of last ping command. |
List<?> |
getListAttribute(String name)
Get List attribute by name |
Long |
getLongAttribute(String name)
Get boolean attribute by name |
Map<?,?> |
getMapAttribute(String name)
Get Long attribute by name |
String |
getPath()
Get the path for this connection. |
long |
getPendingMessages()
Total number of messages that are pending to be sent to the connection. |
long |
getPendingVideoMessages()
Return pending video messages number. |
long |
getReadBytes()
Total number of bytes read from the connection. |
long |
getReadMessages()
Total number of messages read from the connection. |
String |
getRemoteAddress()
Get the IP address the client is connected from. |
List<String> |
getRemoteAddresses()
Get the IP addresses the client is connected from. |
int |
getRemotePort()
Get the port the client is connected from. |
IScope |
getScope()
Get the scope this is connected to. |
String |
getSessionId()
Get the session id, this may be null . |
Set<?> |
getSetAttribute(String name)
Get Set attribute by name |
Short |
getShortAttribute(String name)
Get Short attribute by name |
String |
getStringAttribute(String name)
Get String attribute by name |
String |
getType()
Get the connection type. |
long |
getWrittenBytes()
Total number of bytes written to the connection. |
long |
getWrittenMessages()
Total number of messages written to the connection. |
boolean |
handleEvent(IEvent event)
Handle an event |
boolean |
hasAttribute(String name)
Check the object has an attribute. |
void |
initialize(IClient client)
Initialize the connection. |
boolean |
isConnected()
Is the client connected to the scope. |
void |
notifyEvent(IEvent event)
Notify of event. |
void |
ping()
Start measuring the roundtrip time for a packet on the connection. |
boolean |
removeAttribute(String name)
Remove an attribute. |
void |
removeAttributes()
Remove all attributes. |
void |
removeHeader(String name)
Tell the client to no longer send a header with all further requests. |
void |
removeListener(IConnectionListener listener)
Removes the listener from this object |
boolean |
setAttribute(String name,
Object value)
Set an attribute on this object. |
boolean |
setAttributes(IAttributeStore values)
Set multiple attributes on this object. |
boolean |
setAttributes(Map<String,Object> values)
Set multiple attributes on this object. |
void |
setBandwidth(int mbits)
Sets the bandwidth using a mbit/s value. |
protected void |
setPacket(RemotingPacket packet)
Update the current packet. |
int |
size()
Size of the attribute store. |
String |
toString()
Return string representation of the connection. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Field Detail |
---|
protected IScope scope
protected javax.servlet.http.HttpServletRequest request
protected RemotingPacket packet
protected javax.servlet.http.HttpSession session
protected List<IRemotingHeader> headers
protected CopyOnWriteArrayList<IConnectionListener> connectionListeners
Constructor Detail |
---|
public RemotingConnection(javax.servlet.http.HttpServletRequest request, IScope scope, RemotingPacket packet)
request
- Servlet requestscope
- Scopepacket
- packetMethod Detail |
---|
public String toString()
toString
in class Object
protected void setPacket(RemotingPacket packet)
packet
- public IConnection.Encoding getEncoding()
getEncoding
in interface IConnection
public String getType()
getType
in interface IConnection
public void initialize(IClient client)
initialize
in interface IConnection
client
- Client object associated with connectionpublic boolean connect(IScope scope)
connect
in interface IConnection
scope
- Scope object
true
on success, false
otherwisepublic boolean connect(IScope scope, Object[] params)
connect
in interface IConnection
scope
- Scope objectparams
- Connections parameters
true
on success, false
otherwisepublic boolean isConnected()
true
for persistent and polling connections, false
for transient.
isConnected
in interface IConnection
true
if the connection is persistent or polling,
otherwise false
public void close()
close
in interface IConnection
public Map<String,Object> getConnectParams()
getConnectParams
in interface IConnection
public IClient getClient()
getClient
in interface IConnection
public String getHost()
getHost
in interface IConnection
public String getRemoteAddress()
getRemoteAddress
in interface IConnection
public List<String> getRemoteAddresses()
getRemoteAddresses
in interface IConnection
public int getRemotePort()
getRemotePort
in interface IConnection
public String getPath()
getPath
in interface IConnection
public String getSessionId()
null
.
getSessionId
in interface IConnection
public long getReadBytes()
getReadBytes
in interface IConnection
public long getWrittenBytes()
getWrittenBytes
in interface IConnection
public long getPendingMessages()
getPendingMessages
in interface IConnection
public long getPendingVideoMessages()
public long getReadMessages()
getReadMessages
in interface IConnection
public long getWrittenMessages()
getWrittenMessages
in interface IConnection
public long getDroppedMessages()
getDroppedMessages
in interface IConnection
public void ping()
ping
in interface IConnection
public int getLastPingTime()
getLastPingTime
in interface IConnection
public IScope getScope()
getScope
in interface IConnection
public Iterator<IBasicScope> getBasicScopes()
getBasicScopes
in interface IConnection
public void dispatchEvent(Object event)
public void dispatchEvent(IEvent event)
dispatchEvent
in interface IEventDispatcher
event
- Event objectpublic boolean handleEvent(IEvent event)
handleEvent
in interface IEventHandler
event
- event to handle
public void notifyEvent(IEvent event)
notifyEvent
in interface IEventListener
event
- the event objectpublic Boolean getBoolAttribute(String name)
getBoolAttribute
in interface ICastingAttributeStore
name
- Attribute name
public Byte getByteAttribute(String name)
getByteAttribute
in interface ICastingAttributeStore
name
- Attribute name
public Double getDoubleAttribute(String name)
getDoubleAttribute
in interface ICastingAttributeStore
name
- Attribute name
public Integer getIntAttribute(String name)
getIntAttribute
in interface ICastingAttributeStore
name
- Attribute name
public List<?> getListAttribute(String name)
getListAttribute
in interface ICastingAttributeStore
name
- Attribute name
public Long getLongAttribute(String name)
getLongAttribute
in interface ICastingAttributeStore
name
- Attribute name
public Map<?,?> getMapAttribute(String name)
getMapAttribute
in interface ICastingAttributeStore
name
- Attribute name
public Set<?> getSetAttribute(String name)
getSetAttribute
in interface ICastingAttributeStore
name
- Attribute name
public Short getShortAttribute(String name)
getShortAttribute
in interface ICastingAttributeStore
name
- Attribute name
public String getStringAttribute(String name)
getStringAttribute
in interface ICastingAttributeStore
name
- Attribute name
public Object getAttribute(String name)
getAttribute
in interface IAttributeStore
name
- the name of the attribute to get
public Object getAttribute(String name, Object defaultValue)
This is a utility function that internally performs the following code:
if (!hasAttribute(name)) setAttribute(name, defaultValue);
return getAttribute(name);
getAttribute
in interface IAttributeStore
name
- the name of the attribute to getdefaultValue
- the value of the attribute to set if the attribute doesn't
exist
public Set<String> getAttributeNames()
getAttributeNames
in interface IAttributeStore
getAttributeNames
in interface AttributeStoreMXBean
public Map<String,Object> getAttributes()
getAttributes
in interface IAttributeStore
public boolean hasAttribute(String name)
hasAttribute
in interface IAttributeStore
hasAttribute
in interface AttributeStoreMXBean
name
- the name of the attribute to check
public boolean removeAttribute(String name)
removeAttribute
in interface IAttributeStore
removeAttribute
in interface AttributeStoreMXBean
name
- the name of the attribute to remove
public void removeAttributes()
removeAttributes
in interface IAttributeStore
removeAttributes
in interface AttributeStoreMXBean
public int size()
size
in interface IAttributeStore
public boolean setAttribute(String name, Object value)
setAttribute
in interface IAttributeStore
name
- the name of the attribute to changevalue
- the new value of the attribute
public boolean setAttributes(Map<String,Object> values)
setAttributes
in interface IAttributeStore
values
- the attributes to set
public boolean setAttributes(IAttributeStore values)
setAttributes
in interface IAttributeStore
values
- the attributes to set
public void setBandwidth(int mbits)
setBandwidth
in interface IConnection
public void addHeader(String name, Object value)
addHeader
in interface IRemotingConnection
name
- name of the header to addvalue
- value of the header to addpublic void addHeader(String name, Object value, boolean mustUnderstand)
addHeader
in interface IRemotingConnection
name
- name of the header to addvalue
- value of the header to addmustUnderstand
- a boolean flag specifying if the server must pocess this header
before handling following headers or messagespublic void removeHeader(String name)
removeHeader
in interface IRemotingConnection
name
- name of the header to removepublic Collection<IRemotingHeader> getHeaders()
getHeaders
in interface IRemotingConnection
public long getClientBytesRead()
getClientBytesRead
in interface IConnection
BytesRead
public void cleanup()
public void addListener(IConnectionListener listener)
addListener
in interface IConnection
public void removeListener(IConnectionListener listener)
removeListener
in interface IConnection
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |