public abstract class XMPPTransportHandler extends Object implements TransportHandler<org.jivesoftware.smack.packet.Message>
| Modifier and Type | Field and Description |
|---|---|
protected String |
server |
protected int |
timeoutInterval |
DEFAULT_TIMEOUT_INTERVAL| Modifier | Constructor and Description |
|---|---|
protected |
XMPPTransportHandler(String server)
Constructor for XMPPTransportHandler passing only the server-IP.
|
protected |
XMPPTransportHandler(String server,
int port)
Constructor for XMPPTransportHandler passing server-IP and the XMPP-port.
|
protected |
XMPPTransportHandler(String server,
int port,
int timeoutInterval)
Constructor for XMPPTransportHandler passing server-IP, the XMPP-port and the
timeoutInterval used by listeners to the server and for reconnection schedules.
|
| Modifier and Type | Method and Description |
|---|---|
void |
closeConnection()
Closes the connection to the XMPP Server.
|
protected void |
connectToServer()
Connects to the XMPP-Server and if attempt unsuccessful, then throws exception.
|
protected void |
disableDebugger()
Disables default debugger provided by the XMPPConnection.
|
boolean |
isConnected()
Checks whether the connection to the XMPP-Server persists.
|
protected void |
loginToServer(String username,
String password,
String resource)
If successfully established connection, then tries to Log in using the device's XMPP
Account credentials.
|
protected void |
sendXMPPMessage(String JID,
org.jivesoftware.smack.packet.Message xmppMessage)
Sends an XMPP message.
|
protected void |
sendXMPPMessage(String JID,
String message)
Sends an XMPP message.
|
protected void |
sendXMPPMessage(String JID,
String message,
String subject)
Overloaded method to send an XMPP message.
|
protected void |
setFilterOnReceiver(String receiverJID)
Sets a filter for all the incoming XMPP-Messages on the Receiver's JID (XMPP-Account ID).
|
protected void |
setFilterOnSender(String senderJID)
Sets a filter for all the incoming XMPP-Messages on the Sender's JID (XMPP-Account ID).
|
protected void |
setMessageFilterAndListener(String senderJID,
String receiverJID,
boolean andCondition)
Sets a filter for all the incoming XMPP-Messages on the From-JID & To-JID (XMPP-Account IDs)
passed in.
|
void |
setTimeoutInterval(int millis)
Sets the client's time-out-limit whilst waiting for XMPP-replies from server.
|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitconnect, disconnect, processIncomingMessage, processIncomingMessage, publishDeviceData, publishDeviceDataprotected String server
protected int timeoutInterval
protected XMPPTransportHandler(String server)
server - the IP of the XMPP server.protected XMPPTransportHandler(String server, int port)
server - the IP of the XMPP server.port - the XMPP server's port to connect to. (default - 5222)protected XMPPTransportHandler(String server, int port, int timeoutInterval)
server - the IP of the XMPP server.port - the XMPP server's port to connect to. (default - 5222)timeoutInterval - the timeout interval to use for the connection and reconnectionpublic void setTimeoutInterval(int millis)
millis - the time in millis to be set as the time-out-limit whilst waiting for a
XMPP-reply.public boolean isConnected()
isConnected in interface TransportHandler<org.jivesoftware.smack.packet.Message>protected void connectToServer()
throws TransportHandlerException
TransportHandlerException - in the event of 'Connecting to' the XMPP server fails.protected void loginToServer(String username, String password, String resource) throws TransportHandlerException
username - the username of the device's XMPP-Account.password - the password of the device's XMPP-Account.resource - the resource the resource, specific to the XMPP-Account to which the login
is made toTransportHandlerException - in the event of 'Logging into' the XMPP server fails.protected void setFilterOnSender(String senderJID)
senderJID - the JID (XMPP-Account ID of the sender) to which the filter is to be set.protected void setFilterOnReceiver(String receiverJID)
receiverJID - the JID (XMPP-Account ID of the receiver) to which the filter is to be
set.protected void setMessageFilterAndListener(String senderJID, String receiverJID, boolean andCondition)
senderJID - the From-JID (XMPP-Account ID) to which the filter is to be set.receiverJID - the To-JID (XMPP-Account ID) to which the filter is to be set.andCondition - if true: then filter is set with 'AND' operator (senderJID &&
receiverJID),
if false: then the filter is set with 'OR' operator (senderJID |
receiverJID)protected void sendXMPPMessage(String JID, String message)
JID - the JID (XMPP Account ID) to which the message is to be sent to.message - the XMPP-Message that is to be sent.protected void sendXMPPMessage(String JID, String message, String subject)
JID - the JID (XMPP Account ID) to which the message is to be sent to.message - the XMPP-Message that is to be sent.subject - the subject that the XMPP-Message would carry.protected void sendXMPPMessage(String JID, org.jivesoftware.smack.packet.Message xmppMessage)
JID - the JID (XMPP Account ID) to which the message is to be sent to.xmppMessage - the XMPP-Message that is to be sent.protected void disableDebugger()
public void closeConnection()
Copyright © 2017 WSO2. All rights reserved.