|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--com.realtime.xmpp.util.RestartingEndpoint
An XMPP endpoint for a Jabber server. Maintains a connection to a Jabber server using the host, port, and namespace specified in the constructor.
Use start() to start the component and establish a connection to the Jabber server, and stop() to break the connection.
The component will re-establish failed connections by using the XmppSessionRestarter class.
Field Summary | |
protected XmppSession |
m_session
The XMPP session to the Jabber server. |
protected XmppSessionRestarter |
m_sessionRestarter
A session restarter, to keep-alive the session. |
static long |
XMPP_REQUEST_TIMEOUT
A reasonable default XMPP request timeout in milliseconds. |
Constructor Summary | |
RestartingEndpoint(java.lang.String sHost,
int nPort,
java.lang.String sNamespace)
Create a Jabber component connected to a specific host and port, and using one of the four namespaces. |
|
RestartingEndpoint(XmlStreamFactory streamFactory,
java.lang.String sNamespace)
Create a Jabber component connected to a specific host and port, and using one of the four namespaces. |
Method Summary | |
void |
fastStart()
Starts the component. |
JID |
getComponentName()
Provide the name of this component. |
XmppSession |
getSession()
Provide the underlying XMPP session. |
void |
start()
Starts the component. |
void |
stop()
Stop the component and close the stream to the server. |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Methods inherited from interface com.realtime.xmpp.XmppEndpoint |
send |
Field Detail |
protected XmppSession m_session
protected XmppSessionRestarter m_sessionRestarter
public static final long XMPP_REQUEST_TIMEOUT
Constructor Detail |
public RestartingEndpoint(XmlStreamFactory streamFactory, java.lang.String sNamespace)
Create a Jabber component connected to a specific host and port, and using one of the four namespaces. The session will not be created until start() is called. Start also authenticates with the server using the provided secret.
streamFactory
- An XML stream factory.sNamespace
- The Jabber namespace to use.public RestartingEndpoint(java.lang.String sHost, int nPort, java.lang.String sNamespace)
Create a Jabber component connected to a specific host and port, and using one of the four namespaces. The session will not be created until start() is called. Start also authenticates with the server using the provided secret.
sHost
- The host name to connect to.nPort
- The server port to connect to.sNamespace
- The Jabber namespace to use.Method Detail |
public XmppSession getSession()
Provide the underlying XMPP session. The session might be open or closed.
getSession
in interface XmppEndpoint
public void fastStart() throws java.io.IOException
Starts the component. Opens the socket and starts XMPP streaming. If you are interested in the XMPP session lifecycle events, then register using getSession().addListener().
NOTE: This is a non-blocking call and will likely return BEFORE the stream is ready to write to. If you want to know when the stream is ready for writing, call getSession().waitForOpen() or write an XmppSessionListener and look for the SESSION_STARTED event.
fastStart
in interface XmppEndpoint
java.io.IOException
- Generated when the component could not start.public void start() throws java.io.IOException
Starts the component. Opens the socket and starts XMPP streaming. If you are interested in the XMPP session lifecycle events, then register using getSession().addListener().
This is a blocking call and uses getSession().waitForOpen() to wait until the stream has been established. Uses the default XMPP request timeout of 20 seconds.
start
in interface XmppEndpoint
java.io.IOException
- Generated when the component could not start.public void stop()
Stop the component and close the stream to the server. Also disable the sesson restarter.
stop
in interface XmppEndpoint
public JID getComponentName()
Provide the name of this component. This method will only work AFTER a session has been started.
* @return The name of this component.
getComponentName
in interface XmppEndpoint
|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |