Package org.red5.server.api
Interface IConnection
- All Superinterfaces:
AttributeStoreMXBean
,IAttributeStore
,ICastingAttributeStore
,ICoreObject
,IEventDispatcher
,IEventHandler
,IEventListener
- All Known Subinterfaces:
IRemotingConnection
,IServiceCapableConnection
,IStreamCapableConnection
- All Known Implementing Classes:
BaseConnection
,RTMPConnection
,RTMPMinaConnection
The connection object.
Each connection has an associated client and scope. Connections may be persistent, polling, or transient. The aim of this interface is to provide basic connection methods shared between different types of connections.
- Author:
- The Red5 Project, Luke Hubbard (luke@codegent.com), Paul Gregoire (mondain@gmail.com)
-
Nested Class Summary
-
Field Summary
-
Method Summary
Modifier and TypeMethodDescriptionvoid
addListener
(IConnectionListener listener) Adds a listener to this objectvoid
close()
Close this connection.boolean
Try to connect to the scope.boolean
Try to connect to the scope with a list of connection parameters.Get the basic scopes this connection has subscribed.Get the client object associated with this connection.long
Return number of written bytes the client reports to have received.Return the parameters that were given in the call to "connect".long
Total number of messages that have been dropped.Get the object encoding in use for this connection.getHost()
Get the hostname that the client is connected to.int
Return round-trip time of last ping command.getPath()
Get the path for this connection.long
Total number of messages that are pending to be sent to the connection.Returns the protocol type for this connection.long
Total number of bytes read from the connection.long
Total number of messages read from the connection.Get the IP address the client is connected from.Get the IP addresses the client is connected from.int
Get the port the client is connected from.getScope()
Get the scope this is connected to.Get the session id, this may be null.Returns the current stream id.getType()
Get the connection type.long
Total number of bytes written to the connection.long
Total number of messages written to the connection.void
initialize
(IClient client) Initialize the connection.boolean
Is the client connected to the scope.void
ping()
Start measuring the round-trip time for a packet on the connection.void
removeListener
(IConnectionListener listener) Removes the listener from this objectvoid
setBandwidth
(int mbits) Sets the bandwidth using a mbit/s value.void
Sets the Client.void
setStreamId
(Number id) Sets the current stream id.Methods inherited from interface org.red5.server.api.IAttributeStore
getAttribute, getAttribute, getAttributeNames, getAttributes, hasAttribute, removeAttribute, removeAttributes, setAttribute, setAttributes, setAttributes, size
Methods inherited from interface org.red5.server.api.ICastingAttributeStore
getBoolAttribute, getByteAttribute, getDoubleAttribute, getIntAttribute, getListAttribute, getLongAttribute, getMapAttribute, getSetAttribute, getShortAttribute, getStringAttribute
Methods inherited from interface org.red5.server.api.event.IEventDispatcher
dispatchEvent
Methods inherited from interface org.red5.server.api.event.IEventHandler
handleEvent
Methods inherited from interface org.red5.server.api.event.IEventListener
notifyEvent
-
Field Details
-
PERSISTENT
Persistent connection type, eg RTMP.- See Also:
-
POLLING
Polling connection type, eg RTMPT.- See Also:
-
TRANSIENT
Transient connection type, eg Remoting, HTTP, etc.- See Also:
-
-
Method Details
-
getType
String getType()Get the connection type.- Returns:
- string containing one of connection types
-
getEncoding
IConnection.Encoding getEncoding()Get the object encoding in use for this connection.- Returns:
- encoding type
-
initialize
Initialize the connection.- Parameters:
client
- Client object associated with connection
-
connect
Try to connect to the scope.- Parameters:
scope
- Scope object- Returns:
- true on success, false otherwise
-
connect
Try to connect to the scope with a list of connection parameters.- Parameters:
params
- Connections parametersscope
- Scope object- Returns:
- true on success, false otherwise
-
isConnected
boolean isConnected()Is the client connected to the scope. Result depends on connection type, true for persistent and polling connections, false for transient.- Returns:
- true if the connection is persistent or polling, otherwise false
-
close
void close()Close this connection. This will disconnect the client from the associated scope. -
getConnectParams
Return the parameters that were given in the call to "connect".- Returns:
- Connection parameters passed from client-side (Flex/Flash application)
-
setClient
Sets the Client.- Parameters:
client
- client
-
getClient
IClient getClient()Get the client object associated with this connection.- Returns:
- Client object
-
getHost
String getHost()Get the hostname that the client is connected to. If they are connected to an IP, the IP address will be returned as a String.- Returns:
- String containing the hostname
-
getRemoteAddress
String getRemoteAddress()Get the IP address the client is connected from.- Returns:
- The IP address of the client
-
getRemoteAddresses
Get the IP addresses the client is connected from. If a client is connected through RTMPT and uses a proxy to connect, this will contain all hosts the client used to connect to the server.- Returns:
- The IP addresses of the client
-
getRemotePort
int getRemotePort()Get the port the client is connected from.- Returns:
- The port of the client
-
getPath
String getPath()Get the path for this connection. This is not updated if you switch scope.- Returns:
- path Connection path
-
getSessionId
String getSessionId()Get the session id, this may be null.- Returns:
- Session id
-
getReadBytes
long getReadBytes()Total number of bytes read from the connection.- Returns:
- Number of read bytes
-
getWrittenBytes
long getWrittenBytes()Total number of bytes written to the connection.- Returns:
- Number of written bytes
-
getReadMessages
long getReadMessages()Total number of messages read from the connection.- Returns:
- Number of read messages
-
getWrittenMessages
long getWrittenMessages()Total number of messages written to the connection.- Returns:
- Number of written messages
-
getDroppedMessages
long getDroppedMessages()Total number of messages that have been dropped.- Returns:
- Number of dropped messages
-
getPendingMessages
long getPendingMessages()Total number of messages that are pending to be sent to the connection.- Returns:
- Number of pending messages
-
getClientBytesRead
long getClientBytesRead()Return number of written bytes the client reports to have received. This is the last value of the BytesRead message received from a client.- Returns:
- number of written bytes received by the client
- See Also:
-
ping
void ping()Start measuring the round-trip time for a packet on the connection. -
getLastPingTime
int getLastPingTime()Return round-trip time of last ping command.- Returns:
- round-trip time in milliseconds
-
getScope
IScope getScope()Get the scope this is connected to.- Returns:
- The connected scope
-
getBasicScopes
Iterator<IBasicScope> getBasicScopes()Get the basic scopes this connection has subscribed. This list will contain the shared objects and broadcast streams the connection connected to.- Returns:
- List of basic scopes
-
setBandwidth
void setBandwidth(int mbits) Sets the bandwidth using a mbit/s value.- Parameters:
mbits
- target
-
addListener
Adds a listener to this object- Parameters:
listener
- connection listener
-
removeListener
Removes the listener from this object- Parameters:
listener
- connection listener
-
getStreamId
Number getStreamId()Returns the current stream id.- Returns:
- stream id
-
setStreamId
Sets the current stream id.- Parameters:
id
- stream id
-
getProtocol
String getProtocol()Returns the protocol type for this connection. eg. rtmp, rtmpt, http- Returns:
- protocol type
-