|
Jive Messenger 2.2.2 Javadoc | ||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.jivesoftware.messenger.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.
Field Summary | |
---|---|
static String |
CHARSET
The utf-8 charset for decoding and encoding XMPP packet streams. |
Constructor Summary | |
---|---|
SocketConnection(PacketDeliverer deliverer,
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(Packet packet)
Delivers the packet to this connection without checking the recipient. |
void |
deliverRawText(String text)
Delivers raw text to this connection. |
InetAddress |
getInetAddress()
Returns the InetAddress describing the connection. |
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. |
Writer |
getWriter()
Returns the Writer used to send data to the connection. |
void |
init(Session owner)
Initializes the connection with it's owning session. |
boolean |
isClosed()
Returns true if the connection/session is closed. |
boolean |
isFlashClient()
Returns true if the connected client is a flash client. |
boolean |
isSecure()
Returns true if this connection is secure. |
Object |
registerCloseListener(ConnectionCloseListener listener,
Object handbackMessage)
Registers a listener for close event notification. |
Object |
removeCloseListener(ConnectionCloseListener listener)
Removes a registered close event listener. |
void |
setFlashClient(boolean flashClient)
Sets whether the connected client is a flash client. |
void |
setLanaguage(String language)
Sets the language code that should be used for this connection (e.g. |
void |
setXMPPVersion(int majorVersion,
int minorVersion)
Sets the XMPP version information. |
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 String CHARSET
Constructor Detail |
---|
public SocketConnection(PacketDeliverer deliverer, Socket socket, boolean isSecure) throws IOException
deliverer
- the packet deliverer this connection will use.socket
- the socket to represent.isSecure
- true if this is a secure connection.
NullPointerException
- if the socket is null.
IOException
Method Detail |
---|
public boolean validate()
Connection
validate
in interface Connection
public void init(Session owner)
Connection
init
in interface Connection
owner
- the session that owns this connectionpublic Object registerCloseListener(ConnectionCloseListener listener, Object handbackMessage)
Connection
registerCloseListener
in interface Connection
listener
- the listener to register for events.handbackMessage
- the object to send in the event notification.
public Object removeCloseListener(ConnectionCloseListener listener)
Connection
removeCloseListener
in interface Connection
listener
- the listener to deregister for close events.
public InetAddress getInetAddress()
Connection
getInetAddress
in interface Connection
public Writer getWriter()
Connection
Connection.deliver(Packet)
method should be used to send data instead of using the writer directly.
You must synchronize on the writer before writing data to it to ensure
data consistency:
Writer writer = connection.getWriter(); synchronized(writer) { // write data.... }
getWriter
in interface Connection
public boolean isClosed()
Connection
isClosed
in interface Connection
public boolean isSecure()
Connection
isSecure
in interface Connection
public int getMajorXMPPVersion()
Connection
getMajorXMPPVersion
in interface Connection
public int getMinorXMPPVersion()
Connection
getMinorXMPPVersion
in interface Connection
public void setXMPPVersion(int majorVersion, int minorVersion)
majorVersion
- the major version.minorVersion
- the minor version.public String getLanguage()
Connection
getLanguage
in interface Connection
public void setLanaguage(String language)
language
- the language code.public boolean isFlashClient()
Connection
isFlashClient
in interface Connection
public void setFlashClient(boolean flashClient)
flashClient
- true if the if the connection is a flash client.public void close()
Connection
close
in interface Connection
public void deliver(Packet packet) throws UnauthorizedException, PacketException
Connection
socket.send(packet.getWriteBuffer())
.
deliver
in interface Connection
packet
- the packet to deliver.
UnauthorizedException
PacketException
public void deliverRawText(String text)
Connection
Connection.deliver(org.xmpp.packet.Packet)
.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 String toString()
toString
in class Object
|
Jive Messenger 2.2.2 Javadoc | ||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |