public abstract class BaseConnection extends AttributeStore implements IConnection
IConnection.Duty, IConnection.Encoding, IConnection.Type| Modifier and Type | Field and Description |
|---|---|
protected CopyOnWriteArraySet<IBasicScope> |
basicScopes
Set of basic scopes.
|
protected IClient |
client
Client bound to connection
|
protected CopyOnWriteArrayList<IConnectionListener> |
connectionListeners
Listeners
|
protected AtomicLong |
droppedMessages
Number of dropped messages
|
protected IConnection.Duty |
duty
Duty type
|
protected String |
host
Connection host
|
protected Map<String,Object> |
params
Connection params passed from client with NetConnection.connect call
|
protected String |
path
Path of scope client connected to
|
protected AtomicLong |
readMessages
Number of read messages
|
protected String |
remoteAddress
Connection remote address
|
protected List<String> |
remoteAddresses
Connection remote addresses
|
protected int |
remotePort
Remote port
|
protected Scope |
scope
Scope to which this connection belongs
|
protected String |
sessionId
Connection session identifier
|
protected IConnection.Type |
type
Connection type
|
protected AtomicLong |
writtenMessages
Number of written messages
|
attributes| Constructor and Description |
|---|
BaseConnection()
Creates a new persistent base connection
|
BaseConnection(String type)
Creates a new base connection with the given type.
|
BaseConnection(String type,
String host,
String remoteAddress,
int remotePort,
String path,
String sessionId,
Map<String,Object> params)
Creates a new base connection with the given parameters.
|
| Modifier and Type | Method and Description |
|---|---|
void |
addListener(IConnectionListener listener)
Adds a listener to this object
|
void |
close()
Closes connection
|
boolean |
connect(IScope newScope)
Connect to another scope on server
|
boolean |
connect(IScope newScope,
Object[] params)
Connect to another scope on server with given parameters
|
void |
dispatchEvent(IEvent event)
Dispatches event
|
boolean |
equals(Object obj) |
Iterator<IBasicScope> |
getBasicScopes()
Get the basic scopes this connection has subscribed.
|
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 connection parameters
|
long |
getDroppedMessages()
Total number of messages that have been dropped.
|
IConnection.Duty |
getDuty()
Get the duty for this connection; this is not meant nor expected to remain static.
|
String |
getHost()
Get the hostname that the client is connected to.
|
Semaphore |
getLock() |
String |
getPath()
Get the path for this connection.
|
long |
getPendingMessages()
Count of outgoing messages not yet written.
|
long |
getPendingVideoMessages(Number streamId)
Count of outgoing video messages not yet written.
|
abstract 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()
Return the current scope.
|
String |
getSessionId()
Get the session id, this may be null.
|
Number |
getStreamId()
Returns the current stream id.
|
String |
getType()
Get the connection type.
|
abstract long |
getWrittenBytes()
Total number of bytes written to the connection.
|
long |
getWrittenMessages()
Total number of messages written to the connection.
|
boolean |
handleEvent(IEvent event)
Handles event
|
int |
hashCode() |
void |
initialize(IClient client)
Initializes client
|
boolean |
isClosed()
Returns whether or not a connection is closed.
|
boolean |
isConnected()
Check whether connection is alive
|
boolean |
isReaderIdle()
Returns whether or not the reader is idle.
|
boolean |
isWriterIdle()
Returns whether or not the writer is idle.
|
void |
notifyEvent(IEvent event)
Notified on event
|
void |
registerBasicScope(IBroadcastScope basicScope)
Registers basic scope
|
void |
registerBasicScope(SharedObjectScope basicScope)
Registers basic scope
|
void |
removeListener(IConnectionListener listener)
Removes the listener from this object
|
void |
setClient(IClient client)
Sets the Client.
|
void |
setDuty(IConnection.Duty duty) |
void |
setStreamId(Number id)
Sets the current stream id.
|
void |
unregisterBasicScope(IBasicScope basicScope)
Unregister basic scope
|
filterNull, from, getAttribute, getAttribute, getAttributeNames, getAttributes, getBoolAttribute, getByteAttribute, getDoubleAttribute, getIntAttribute, getListAttribute, getLongAttribute, getMapAttribute, getSetAttribute, getShortAttribute, getStringAttribute, hasAttribute, removeAttribute, removeAttributes, setAttribute, setAttributes, setAttributes, sizeclone, finalize, getClass, notify, notifyAll, toString, wait, wait, waitgetEncoding, getLastPingTime, getProtocol, ping, setBandwidthgetBoolAttribute, getByteAttribute, getDoubleAttribute, getIntAttribute, getListAttribute, getLongAttribute, getMapAttribute, getSetAttribute, getShortAttribute, getStringAttributegetAttribute, getAttribute, getAttributeNames, getAttributes, hasAttribute, removeAttribute, removeAttributes, setAttribute, setAttributes, setAttributes, sizeprotected final IConnection.Type type
protected volatile IConnection.Duty duty
protected volatile String host
protected volatile String remoteAddress
protected volatile int remotePort
protected volatile String path
protected final String sessionId
protected AtomicLong readMessages
protected AtomicLong writtenMessages
protected AtomicLong droppedMessages
protected volatile Map<String,Object> params
protected volatile IClient client
protected transient volatile Scope scope
protected transient CopyOnWriteArraySet<IBasicScope> basicScopes
protected transient CopyOnWriteArrayList<IConnectionListener> connectionListeners
@ConstructorProperties(value="persistent") public BaseConnection()
@ConstructorProperties(value="type") public BaseConnection(String type)
type - Connection type@ConstructorProperties(value={"type","host","remoteAddress","remotePort","path","sessionId"}) public BaseConnection(String type, String host, String remoteAddress, int remotePort, String path, String sessionId, Map<String,Object> params)
type - Connection typehost - HostremoteAddress - Remote addressremotePort - Remote portpath - Scope path on serversessionId - Session idparams - Params passed from clientpublic void addListener(IConnectionListener listener)
addListener in interface IConnectionlistener - connection listenerpublic void removeListener(IConnectionListener listener)
removeListener in interface IConnectionlistener - connection listenerpublic Semaphore getLock()
public Number getStreamId()
getStreamId in interface IConnectionpublic void setStreamId(Number id)
setStreamId in interface IConnectionid - stream idpublic void initialize(IClient client)
initialize in interface IConnectionclient - Client bound to connectionpublic String getType()
getType in interface IConnectionpublic IConnection.Duty getDuty()
getDuty in interface IConnectionpublic void setDuty(IConnection.Duty duty)
public 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()
getSessionId in interface IConnectionpublic Map<String,Object> getConnectParams()
getConnectParams in interface IConnectionpublic void setClient(IClient client)
setClient in interface IConnectionclient - clientpublic IClient getClient()
getClient in interface IConnectionpublic boolean isConnected()
isConnected in interface IConnectionpublic boolean connect(IScope newScope)
connect in interface IConnectionnewScope - New scopepublic boolean connect(IScope newScope, Object[] params)
connect in interface IConnectionnewScope - New scopeparams - Parameters to connect withpublic IScope getScope()
getScope in interface IConnectionpublic void close()
close in interface IConnectionpublic void notifyEvent(IEvent event)
notifyEvent in interface IEventListenerevent - Eventpublic void dispatchEvent(IEvent event)
dispatchEvent in interface IEventDispatcherevent - Eventpublic boolean handleEvent(IEvent event)
handleEvent in interface IEventHandlerevent - Eventpublic Iterator<IBasicScope> getBasicScopes()
IConnectiongetBasicScopes in interface IConnectionpublic void registerBasicScope(IBroadcastScope basicScope)
basicScope - Basic scope to registerpublic void registerBasicScope(SharedObjectScope basicScope)
basicScope - Basic scope to registerpublic void unregisterBasicScope(IBasicScope basicScope)
basicScope - Unregister basic scopepublic abstract long getReadBytes()
IConnectiongetReadBytes in interface IConnectionpublic abstract long getWrittenBytes()
IConnectiongetWrittenBytes in interface IConnectionpublic long getReadMessages()
IConnectiongetReadMessages in interface IConnectionpublic long getWrittenMessages()
IConnectiongetWrittenMessages in interface IConnectionpublic long getDroppedMessages()
IConnectiongetDroppedMessages in interface IConnectionpublic boolean isReaderIdle()
public boolean isWriterIdle()
public boolean isClosed()
public long getPendingMessages()
getPendingMessages in interface IConnectionpublic long getPendingVideoMessages(Number streamId)
streamId - the id you want to know aboutpublic long getClientBytesRead()
getClientBytesRead in interface IConnectionBytesReadCopyright © 2005–2017 Red5. All rights reserved.