public class RemotingConnection extends Object implements IRemotingConnection
IConnection.Encoding| Modifier and Type | Field and Description |
|---|---|
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.
|
PERSISTENT, POLLING, TRANSIENT| Constructor and Description |
|---|
RemotingConnection(javax.servlet.http.HttpServletRequest request,
IScope scope,
RemotingPacket packet)
Create servlet connection from request and scope.
|
| Modifier and Type | Method and Description |
|---|---|
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 |
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.
|
boolean |
setAttribute(String name,
Object value)
Set an attribute on this object.
|
void |
setAttributes(IAttributeStore values)
Set multiple attributes on this object.
|
void |
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.
|
String |
toString()
Return string representation of the connection.
|
protected IScope scope
protected javax.servlet.http.HttpServletRequest request
protected RemotingPacket packet
protected javax.servlet.http.HttpSession session
protected List<IRemotingHeader> headers
public RemotingConnection(javax.servlet.http.HttpServletRequest request,
IScope scope,
RemotingPacket packet)
request - Servlet requestscope - Scopepacket - packetpublic String toString()
protected void setPacket(RemotingPacket packet)
packet - public IConnection.Encoding getEncoding()
getEncoding in interface IConnectionpublic String getType()
getType in interface IConnectionpublic void initialize(IClient client)
initialize in interface IConnectionclient - Client object associated with connectionpublic boolean connect(IScope scope)
connect in interface IConnectionscope - Scope objecttrue on success, false otherwisepublic boolean connect(IScope scope, Object[] params)
connect in interface IConnectionscope - Scope objectparams - Connections parameterstrue on success, false otherwisepublic boolean isConnected()
true for persistent and polling connections, false for transient.isConnected in interface IConnectiontrue if the connection is persistent or polling,
otherwise falsepublic void close()
close in interface IConnectionpublic Map<String,Object> getConnectParams()
getConnectParams in interface IConnectionpublic IClient getClient()
getClient in interface IConnectionpublic String getHost()
getHost in interface IConnectionpublic String getRemoteAddress()
getRemoteAddress in interface IConnectionpublic List<String> getRemoteAddresses()
getRemoteAddresses in interface IConnectionpublic int getRemotePort()
getRemotePort in interface IConnectionpublic String getPath()
getPath in interface IConnectionpublic String getSessionId()
null.getSessionId in interface IConnectionpublic long getReadBytes()
getReadBytes in interface IConnectionpublic long getWrittenBytes()
getWrittenBytes in interface IConnectionpublic long getPendingMessages()
getPendingMessages in interface IConnectionpublic long getPendingVideoMessages()
public long getReadMessages()
getReadMessages in interface IConnectionpublic long getWrittenMessages()
getWrittenMessages in interface IConnectionpublic long getDroppedMessages()
getDroppedMessages in interface IConnectionpublic void ping()
ping in interface IConnectionpublic int getLastPingTime()
getLastPingTime in interface IConnectionpublic IScope getScope()
getScope in interface IConnectionpublic Iterator<IBasicScope> getBasicScopes()
getBasicScopes in interface IConnectionpublic void dispatchEvent(Object event)
public void dispatchEvent(IEvent event)
dispatchEvent in interface IEventDispatcherevent - Event objectpublic boolean handleEvent(IEvent event)
handleEvent in interface IEventHandlerevent - event to handlepublic void notifyEvent(IEvent event)
notifyEvent in interface IEventListenerevent - the event objectpublic Boolean getBoolAttribute(String name)
getBoolAttribute in interface ICastingAttributeStorename - Attribute namepublic Byte getByteAttribute(String name)
getByteAttribute in interface ICastingAttributeStorename - Attribute namepublic Double getDoubleAttribute(String name)
getDoubleAttribute in interface ICastingAttributeStorename - Attribute namepublic Integer getIntAttribute(String name)
getIntAttribute in interface ICastingAttributeStorename - Attribute namepublic List<?> getListAttribute(String name)
getListAttribute in interface ICastingAttributeStorename - Attribute namepublic Long getLongAttribute(String name)
getLongAttribute in interface ICastingAttributeStorename - Attribute namepublic Map<?,?> getMapAttribute(String name)
getMapAttribute in interface ICastingAttributeStorename - Attribute namepublic Set<?> getSetAttribute(String name)
getSetAttribute in interface ICastingAttributeStorename - Attribute namepublic Short getShortAttribute(String name)
getShortAttribute in interface ICastingAttributeStorename - Attribute namepublic String getStringAttribute(String name)
getStringAttribute in interface ICastingAttributeStorename - Attribute namepublic Object getAttribute(String name)
getAttribute in interface IAttributeStorename - the name of the attribute to getpublic 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 IAttributeStorename - the name of the attribute to getdefaultValue - the value of the attribute to set if the attribute doesn't
existpublic Set<String> getAttributeNames()
getAttributeNames in interface IAttributeStoregetAttributeNames in interface AttributeStoreMXBeanpublic Map<String,Object> getAttributes()
getAttributes in interface IAttributeStorepublic boolean hasAttribute(String name)
hasAttribute in interface IAttributeStorehasAttribute in interface AttributeStoreMXBeanname - the name of the attribute to checkpublic boolean removeAttribute(String name)
removeAttribute in interface IAttributeStoreremoveAttribute in interface AttributeStoreMXBeanname - the name of the attribute to removepublic void removeAttributes()
removeAttributes in interface IAttributeStoreremoveAttributes in interface AttributeStoreMXBeanpublic boolean setAttribute(String name, Object value)
setAttribute in interface IAttributeStorename - the name of the attribute to changevalue - the new value of the attributepublic void setAttributes(Map<String,Object> values)
setAttributes in interface IAttributeStorevalues - the attributes to setpublic void setAttributes(IAttributeStore values)
setAttributes in interface IAttributeStorevalues - the attributes to setpublic void setBandwidth(int mbits)
setBandwidth in interface IConnectionpublic void addHeader(String name, Object value)
addHeader in interface IRemotingConnectionname - name of the header to addvalue - value of the header to addpublic void addHeader(String name, Object value, boolean mustUnderstand)
addHeader in interface IRemotingConnectionname - 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 IRemotingConnectionname - name of the header to removepublic Collection<IRemotingHeader> getHeaders()
getHeaders in interface IRemotingConnectionpublic long getClientBytesRead()
getClientBytesRead in interface IConnectionBytesReadpublic void cleanup()
Copyright © 2006-2012 The Red5 Project