public class XMPPStreamManager extends AbstractPacketForwarder implements PacketCollector, XMPPStream
XMPPStreamManager is responsible for managing XMPP stream with
server. It governs the overall stream and hence the communication with
server. Being a central entity, all the inbound and outbound packets pass
through it.| Constructor and Description |
|---|
XMPPStreamManager(XMPPConnection connection)
Instantiate
XMPPStreamManager with given XMPPConnection. |
| Modifier and Type | Method and Description |
|---|---|
void |
closed()
Called when connection is closed
|
void |
closeStream()
Close the ongoing stream.
|
void |
closingConnection()
Method call to inform the dependent entities that after this method call
the connection will be closed.
|
void |
collect(Packet packet)
This collector takes the given packet.
|
void |
connected()
Invoked when physical connection is established with server.
|
void |
resetStream()
Reset Stream to its initial state.
|
StreamNegotiator.NegotiationResult |
restartStream()
Restart a broken stream.
|
boolean |
sendPacketAsync(Stanza stanza)
Send stanza packet to server; Stanza packets are delivered to server
asynchronously.This methos simply adds the stanza to Writer queue and
Writer thread will write the stanza whenver stream is ready
|
void |
shutdown()
Initiate stream manager shutdown sequence.
|
StreamNegotiator.NegotiationResult |
startStream(String userName,
String pwd,
String domain)
Start a stream with server for the first time.
|
addPacketCollector, addPacketCollector, forwardDefault, forwardPacket, removePacketCollector, removePacketCollectorpublic XMPPStreamManager(XMPPConnection connection)
XMPPStreamManager with given XMPPConnection.
The assumption is that supplied connection will be already connected to
the remote server.connection - underlying connectionpublic StreamNegotiator.NegotiationResult startStream(String userName, String pwd, String domain) throws NetworkException
startStream in interface XMPPStreamuserName - userNamepwd - pwddomain - domainNetworkException - NetworkExceptionpublic StreamNegotiator.NegotiationResult restartStream() throws NetworkException
XMPPStreamConnectionConfig and user
session data to restablish the connection and autentication. Essentially,
the broken connection is re-established.
Stream negotiations are done synchronously. The method returns when stream negotiation is finished.
restartStream in interface XMPPStreamNetworkException - NetworkExceptionpublic void collect(Packet packet)
PacketCollectorcollect in interface PacketCollectorpacket - packet instance to be collectedpublic boolean sendPacketAsync(Stanza stanza)
stanza - packet which will be written on the wirepublic void closeStream()
throws NetworkException
XMPPStreamcloseStream in interface XMPPStreamNetworkException - if an IO error occurrs while sending packetpublic void shutdown()
StreamContext state is reset, Reader and
Writer are shutdown.public void connected()
ConnectionStateObserverconnected in interface ConnectionStateObserverpublic void closingConnection()
ConnectionStateObserverclosingConnection in interface ConnectionStateObserverpublic void closed()
ConnectionStateObserverclosed in interface ConnectionStateObserverpublic void resetStream()
XMPPStreamresetStream in interface XMPPStreamCopyright © 2019. All rights reserved.