|
Connection Manager 3.4.4 Javadoc | ||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.jivesoftware.multiplexer.net.SocketConnection
public class SocketConnection
An object to track the state of a XMPP client-server session. Currently this class contains the socket channel connecting the client and server.
This class was copied from Openfire. PacketInterceptors were removed. Session concept was removed. ConnectionCloseListeners were removed.
Nested Class Summary |
---|
Nested classes/interfaces inherited from interface org.jivesoftware.multiplexer.Connection |
---|
Connection.CompressionPolicy, Connection.TLSPolicy |
Field Summary | |
---|---|
static java.lang.String |
CHARSET
The utf-8 charset for decoding and encoding XMPP packet streams. |
Constructor Summary | |
---|---|
SocketConnection(PacketDeliverer backupDeliverer,
java.net.Socket socket,
boolean isSecure)
Create a new session using the supplied socket. |
Method Summary | |
---|---|
void |
close()
Close this session including associated socket connection. |
void |
deliver(java.lang.String stanza)
Delivers the packet to this connection without checking the recipient. |
void |
deliverRawText(java.lang.String text)
Delivers raw text to this connection. |
Connection.CompressionPolicy |
getCompressionPolicy()
Returns whether compression is optional or is disabled. |
long |
getIdleTimeout()
|
java.net.InetAddress |
getInetAddress()
Returns the InetAddress describing the connection. |
static java.util.Collection<SocketConnection> |
getInstances()
|
java.lang.String |
getLanguage()
Returns the language code that should be used for this connection (e.g. |
int |
getMajorXMPPVersion()
Returns the major version of XMPP being used by this connection (major_version.minor_version. |
int |
getMinorXMPPVersion()
Returns the minor version of XMPP being used by this connection (major_version.minor_version. |
PacketDeliverer |
getPacketDeliverer()
Returns the packet deliverer to use when delivering a packet over the socket fails. |
int |
getPort()
Returns the port that the connection uses. |
javax.net.ssl.SSLSession |
getSSLSession()
|
Connection.TLSPolicy |
getTlsPolicy()
Returns whether TLS is mandatory, optional or is disabled. |
TLSStreamHandler |
getTLSStreamHandler()
Returns the stream handler responsible for securing the plain connection and providing the corresponding input and output streams. |
void |
init(Session owner)
Initializes the connection that is related to the specified session. |
boolean |
isClosed()
Returns true if the connection/session is closed. |
boolean |
isCompressed()
Returns true if the connection is using compression. |
boolean |
isFlashClient()
Returns true if the connected client is a flash client. |
boolean |
isSecure()
Returns true if this connection is secure. |
void |
registerCloseListener(ConnectionCloseListener listener,
java.lang.Object handbackMessage)
Registers a new listener that will react when this connection is closed. |
void |
removeCloseListener(ConnectionCloseListener listener)
Removes a listener that was reacting when this connection was closed. |
void |
setCompressionPolicy(Connection.CompressionPolicy compressionPolicy)
Sets whether compression is enabled or is disabled. |
void |
setFlashClient(boolean flashClient)
Sets whether the connected client is a flash client. |
void |
setIdleTimeout(long timeout)
Sets the number of milliseconds a connection has to be idle to be closed. |
void |
setLanaguage(java.lang.String language)
Sets the language code that should be used for this connection (e.g. |
void |
setSocketStatistic(SocketStatistic socketStatistic)
|
void |
setTlsPolicy(Connection.TLSPolicy tlsPolicy)
Sets whether TLS is mandatory, optional or is disabled. |
void |
setXMPPVersion(int majorVersion,
int minorVersion)
Sets the XMPP version information. |
void |
startCompression()
Start using compression for this connection. |
void |
startTLS(boolean clientMode,
java.lang.String remoteServer)
Secures the plain connection by negotiating TLS with the client. |
void |
systemShutdown()
Notification message indicating that the server is being shutdown. |
java.lang.String |
toString()
|
boolean |
validate()
Verifies that the connection is still live. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Field Detail |
---|
public static final java.lang.String CHARSET
Constructor Detail |
---|
public SocketConnection(PacketDeliverer backupDeliverer, java.net.Socket socket, boolean isSecure) throws java.io.IOException
backupDeliverer
- the packet deliverer this connection will use when socket is closed.socket
- the socket to represent.isSecure
- true if this is a secure connection.
java.lang.NullPointerException
- if the socket is null.
java.io.IOException
Method Detail |
---|
public static java.util.Collection<SocketConnection> getInstances()
public TLSStreamHandler getTLSStreamHandler()
public void startTLS(boolean clientMode, java.lang.String remoteServer) throws java.io.IOException
Connection
true
and
remoteServer is the server name of the remote server. Otherwise clientMode
will be false
and remoteServer null.
startTLS
in interface Connection
clientMode
- boolean indicating if this entity is a client or a server.remoteServer
- server name of the remote server we are connecting to or null
when not in client mode.
java.io.IOException
public void startCompression()
Connection
startCompression
in interface Connection
public boolean validate()
Connection
validate
in interface Connection
public void init(Session owner)
Connection
init
in interface Connection
owner
- the Session that owns this connection.public void registerCloseListener(ConnectionCloseListener listener, java.lang.Object handbackMessage)
Connection
registerCloseListener
in interface Connection
listener
- the new listener.handbackMessage
- the object to send back when notifying that the connection was closed.public void removeCloseListener(ConnectionCloseListener listener)
Connection
removeCloseListener
in interface Connection
listener
- the listener to remove.public java.net.InetAddress getInetAddress()
Connection
getInetAddress
in interface Connection
public int getPort()
public boolean isClosed()
Connection
isClosed
in interface Connection
public boolean isSecure()
Connection
isSecure
in interface Connection
public boolean isCompressed()
Connection
isCompressed
in interface Connection
public Connection.TLSPolicy getTlsPolicy()
Connection
getTlsPolicy
in interface Connection
public void setTlsPolicy(Connection.TLSPolicy tlsPolicy)
setTlsPolicy
in interface Connection
tlsPolicy
- whether TLS is mandatory, optional or is disabled.public Connection.CompressionPolicy getCompressionPolicy()
Connection
getCompressionPolicy
in interface Connection
public void setCompressionPolicy(Connection.CompressionPolicy compressionPolicy)
setCompressionPolicy
in interface Connection
compressionPolicy
- whether Compression is enabled or is disabled.public long getIdleTimeout()
public void setIdleTimeout(long timeout)
timeout
- the number of milliseconds a connection has to be idle to be closed.public int getMajorXMPPVersion()
Connection
getMajorXMPPVersion
in interface Connection
public int getMinorXMPPVersion()
Connection
getMinorXMPPVersion
in interface Connection
public void setXMPPVersion(int majorVersion, int minorVersion)
setXMPPVersion
in interface Connection
majorVersion
- the major version.minorVersion
- the minor version.public java.lang.String getLanguage()
Connection
getLanguage
in interface Connection
public void setLanaguage(java.lang.String language)
setLanaguage
in interface Connection
language
- the language code.public boolean isFlashClient()
Connection
isFlashClient
in interface Connection
public void setFlashClient(boolean flashClient)
setFlashClient
in interface Connection
flashClient
- true if the if the connection is a flash client.public javax.net.ssl.SSLSession getSSLSession()
public PacketDeliverer getPacketDeliverer()
Connection
getPacketDeliverer
in interface Connection
public void close()
Connection
close
in interface Connection
public void systemShutdown()
Connection
systemShutdown
in interface Connection
public void deliver(java.lang.String stanza)
Connection
socket.send(packet.getWriteBuffer())
.
deliver
in interface Connection
stanza
- the stanza to deliver.public void deliverRawText(java.lang.String text)
Connection
Connection.deliver(String)
.This method avoids having to get the writer of this connection and mess directly with the writer. Therefore, this method ensures a correct delivery of the stanza even if other threads were sending data concurrently.
deliverRawText
in interface Connection
text
- the XML stanzas represented kept in a String.public java.lang.String toString()
toString
in class java.lang.Object
public void setSocketStatistic(SocketStatistic socketStatistic)
|
Connection Manager 3.4.4 Javadoc | ||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |