|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--org.jabber.jabberbeans.ConnectionBean
ConnectionBean is the main bean for JabberBeans.
A ConnectionBean models the connection to the server, and all other beans rely on the ConnectionBean for server communication.
Internally, a ConnectionBean is just a "standard" interface to the backend (by default, Jabberbeans-SAX) which handles the server communication - you simply create objects and push them through 'send' to get to the server, and subscribe to the right interfaces to 'receive' new objects as they come in.
All the other beans (MessengerBean, IQBean, and RosterBean so far) are considered optional. Internally, they just use the ConnectionBean to send data, and listen to the events being broadcasted by the ConnectionBean to filter their 'received' data (which they then rebroadcast to their respective listeners.)
MessengerBean
,
IQBean
,
RosterBean
,
org.jabber.jabberbeans.sax,
Serialized FormNested Class Summary | |
class |
ConnectionBean.InputStreamInterface
|
class |
ConnectionBean.OutputStreamInterface
|
class |
ConnectionBean.XMLStreamMonitor
|
Field Summary | |
static int |
CONNECTION_TIMEOUT
the default time is 10000 ms or 10 seconds |
static int |
DEFAULT_PORT
the default port for jabber servers, 5222 |
protected static java.lang.String |
DEFAULT_XMLSTREAM_NS
Default namespace for XMLStream |
protected boolean |
DisableAutoHeader
used to disable auto-sending XML stream tag |
Constructor Summary | |
ConnectionBean()
|
Method Summary | |
void |
addConnectionListener(ConnectionListener l)
addConnectionListener adds a
ConnectionListener to the list of Listeners to be called
when the connection state changes. |
void |
addPacketListener(PacketListener l)
addPacketListener adds a PacketListener to the
list of Listeners to be called when a packet is received or successfully
sent out. |
void |
connect(java.net.InetAddress host)
connect attempts to establish a connection to the
default port on the specified server. |
void |
connect(java.net.InetAddress host,
int port)
connect attempts to establish a server connection to a
specified port. |
void |
connect(java.net.InetAddress host,
java.lang.String name)
connect attempts to establish a server connection to the
default port. |
void |
connect(java.net.InetAddress host,
java.lang.String name,
int port)
connect attempts to establish a server connection to a
specified port. |
void |
connect(java.io.InputStream is,
java.io.OutputStream os)
Begin communication with a Jabber server. |
void |
connect(java.net.Socket s)
Begin communication with a Jabber server. |
void |
connect(java.net.Socket s,
java.net.InetAddress host)
|
void |
delConnectionListener(ConnectionListener l)
delConnectionListener removes a previously added
ConnectionListener from the list of Listeners to be called
when a connection state change event happens. |
void |
delPacketListener(PacketListener l)
delPacketListener removes a
PacketListener to the list of Listeners to be called when
a packet is received or successfully sent out. |
void |
disableStreamHeader()
|
void |
disconnect()
disconnect correctly closes down the connection to the
Jabber server in the backend. |
protected void |
fireReceivedPacket(Packet packet)
Internal method which sends out packet events on received data. |
protected void |
fireSentPacket(Packet packet)
Internal method which sends out packet events on sent data. |
protected void |
fireUnsentPacket(Packet packet)
Internal method which sends out packet events on failed send data. |
java.net.InetAddress |
getAddress()
|
ConnectionEvent.EState |
getConnectionState()
returns the current connection state (disconnected, connecting, connected). |
java.lang.String |
getParser()
|
java.lang.String |
getSessionID()
|
void |
onInputDeath(java.lang.Exception e)
handler code for input stream death. |
void |
onOutputDeath(java.lang.Exception e)
handler code for output stream death. |
void |
received(Packet packet)
received is the method used to indicate that a new packet
has arrived. |
void |
send(Packet packet)
send is the method used to send all packets to the server. |
protected void |
setConnectionState(ConnectionEvent.EState state,
ConnectionEvent.EReason reason)
internal method which allows you to set the connection state, then broadcast the change to all listening classes. |
void |
setParser(java.lang.String s)
|
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
public static final int DEFAULT_PORT
public static final int CONNECTION_TIMEOUT
protected static final java.lang.String DEFAULT_XMLSTREAM_NS
protected boolean DisableAutoHeader
Constructor Detail |
public ConnectionBean()
Method Detail |
public void setParser(java.lang.String s)
public java.lang.String getParser()
public void connect(java.net.InetAddress host) throws java.io.IOException
connect
attempts to establish a connection to the
default port on the specified server.
host
- InetAddress
of the server
java.io.IOException
- socket error in backendpublic void connect(java.net.InetAddress host, java.lang.String name) throws java.io.IOException
connect
attempts to establish a server connection to the
default port. This version allows you to specify a string, if the
host name the Jabber server expects is different than the one you are
connecting with (e.g. for applets).
host
- InetAddress
of the servername
- String
holding the name to send to the Jabber
server on connection.
java.io.IOException
- socket error in backendpublic void connect(java.net.InetAddress host, int port) throws java.io.IOException
connect
attempts to establish a server connection to a
specified port. This implementation takes a hostname and port.
host
- InetAddress
of the serverport
- an int
specifying the port number
java.io.IOException
- socket error in backendpublic void connect(java.net.InetAddress host, java.lang.String name, int port) throws java.io.IOException
connect
attempts to establish a server connection to a
specified port. This version allows you to specify a string, if the
host name the Jabber server expects is different than the one you are
connecting with (e.g. for applets).
host
- InetAddress
of the servername
- String
holding the name to send to the Jabber
server on connection.port
- an int
specifying the port number
java.io.IOException
- socket error in backendpublic void connect(java.net.Socket s) throws java.io.IOException
s
- Socket
connecting us with the Jabber server.
java.io.IOException
public void connect(java.net.Socket s, java.net.InetAddress host) throws java.io.IOException
java.io.IOException
public void connect(java.io.InputStream is, java.io.OutputStream os) throws java.io.IOException
is
- InputStream
for incoming data from the Jabber
serveros
- OutputStream
for sending data out to the
Jabber server.
java.io.IOException
public final java.net.InetAddress getAddress()
public void disconnect()
disconnect
correctly closes down the connection to the
Jabber server in the backend.
public final void addConnectionListener(ConnectionListener l)
addConnectionListener
adds a
ConnectionListener
to the list of Listeners to be called
when the connection state changes.
l
- a ConnectionListener
. Cannot add the same listener
twicepublic final void delConnectionListener(ConnectionListener l)
delConnectionListener
removes a previously added
ConnectionListener
from the list of Listeners to be called
when a connection state change event happens.
l
- a ConnectionListener
valuepublic final void addPacketListener(PacketListener l)
addPacketListener
adds a PacketListener
to the
list of Listeners to be called when a packet is received or successfully
sent out.
addPacketListener
in interface PacketListenerRegistrar
l
- a PacketListener
valuepublic final void delPacketListener(PacketListener l)
delPacketListener
removes a
PacketListener
to the list of Listeners to be called when
a packet is received or successfully sent out.
delPacketListener
in interface PacketListenerRegistrar
l
- a PacketListener
valuepublic void send(Packet packet)
send
is the method used to send all packets to the server.
A Packet
is a code element that knows how to explain itself
in XML. The Packet
is asynchronously sent to the server,
with registered ConnectionListener
s receiving an event on
successful sending.
packet
- a Packet
being sent to the serverpublic void received(Packet packet)
received
is the method used to indicate that a new packet
has arrived. This method is ONLY meant to be used
by the InputStreamHandler thread. Please avoid the urge to use it.
It will probably become non-accessable in the near future, consider
this a warning.
packet
- a Packet
arriving from the server.protected final void fireReceivedPacket(Packet packet)
packet
- the packet we are sending out to all subscribed listenersprotected final void fireSentPacket(Packet packet)
packet
- the packet we are sending out to all subscribed listenersprotected final void fireUnsentPacket(Packet packet)
packet
- the packet we are sending out to all subscribed listenerspublic void onOutputDeath(java.lang.Exception e)
public void onInputDeath(java.lang.Exception e)
public final ConnectionEvent.EState getConnectionState()
protected final void setConnectionState(ConnectionEvent.EState state, ConnectionEvent.EReason reason)
state
- new state to enter, based on possibilities from
ConnectionEvent.EState
reason
- the reason we are changing statesConnectionEvent.EState
public java.lang.String getSessionID()
public void disableStreamHeader()
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |