Package io.toro.martini.jabber.model
Class JabberConnection
- java.lang.Object
-
- org.jivesoftware.smack.AbstractXMPPConnection
-
- org.jivesoftware.smack.tcp.XMPPTCPConnection
-
- io.toro.martini.jabber.model.JabberConnection
-
- All Implemented Interfaces:
AutoCloseable
,XMPPConnection
- Direct Known Subclasses:
XmppConnection
public class JabberConnection extends XMPPTCPConnection implements AutoCloseable
- Author:
- jerrickpua
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from class org.jivesoftware.smack.tcp.XMPPTCPConnection
XMPPTCPConnection.PacketReader, XMPPTCPConnection.PacketWriter
-
Nested classes/interfaces inherited from class org.jivesoftware.smack.AbstractXMPPConnection
AbstractXMPPConnection.InterceptorWrapper, AbstractXMPPConnection.ListenerWrapper
-
Nested classes/interfaces inherited from interface org.jivesoftware.smack.XMPPConnection
XMPPConnection.FromMode
-
-
Field Summary
Fields Modifier and Type Field Description static int
DEFAULT_CONNECTION_TIMEOUT
static int
DEFAULT_PACKET_REPLY_TIMEOUT
static int
DEFAULT_PING_INTERVAL
-
Fields inherited from class org.jivesoftware.smack.tcp.XMPPTCPConnection
packetReader, packetWriter
-
Fields inherited from class org.jivesoftware.smack.AbstractXMPPConnection
authenticated, compressionHandler, connected, connectionCounterValue, connectionListeners, connectionLock, debugger, host, hostAddresses, lastFeaturesReceived, port, reader, saslAuthentication, saslFeatureReceived, streamFeatures, streamId, user, wasAuthenticated, writer
-
-
Constructor Summary
Constructors Constructor Description JabberConnection(String name, CharSequence jid, String password, boolean allowReconnection, Integer pingInterval)
JabberConnection(String name, CharSequence username, String password, String serviceName, boolean allowReconnection, Integer pingInterval)
JabberConnection(String name, Map configuration)
JabberConnection(String name, XMPPTCPConnectionConfiguration config, boolean allowReconnection, long pingInterval)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description void
addChatListener(ChatManagerListener listener)
static XMPPTCPConnectionConfiguration
buildConfiguration(Map configuration)
Creates a jabber based on the configuration map provided Properties for configuring jabber connection NOTE THIS IS FOR ENDPOINT ONLY{ Key: replyServiceResponse, Type:
- Set to true if service response will return its object to the sender.Boolean
}void
close()
JabberConnection
connect()
protected void
connectInternal()
void
disconnect()
String
getName()
Integer
getPingInterval()
Set<RosterEntry>
getUsers()
void
instantShutdown()
boolean
isAllowReconnection()
void
login()
void
login(CharSequence username, String password)
void
login(CharSequence username, String password, String resource)
void
sendMessage(String jid, String message)
void
sendMessage(String jid, Message message)
void
setName(io.toro.martini.endpoint.Endpoint endpoint)
void
setName(String name)
-
Methods inherited from class org.jivesoftware.smack.tcp.XMPPTCPConnection
addRequestAckPredicate, addStanzaAcknowledgedListener, addStanzaIdAcknowledgedListener, afterFeaturesReceived, afterSuccessfulLogin, getMaxSmResumptionTime, isDisconnectedButSmResumptionPossible, isSecureConnection, isSmAvailable, isSmEnabled, isSmResumptionPossible, isSocketClosed, isUsingCompression, loginAnonymously, loginNonAnonymously, removeAllRequestAckPredicates, removeAllStanzaAcknowledgedListeners, removeAllStanzaIdAcknowledgedListeners, removeRequestAckPredicate, removeStanzaAcknowledgedListener, removeStanzaIdAcknowledgedListener, requestSmAcknowledgement, send, sendSmAcknowledgement, sendStanzaInternal, setBundleandDeferCallback, setDefaultBundleAndDeferCallback, setPreferredResumptionTime, setUseStreamManagement, setUseStreamManagementDefault, setUseStreamManagementResumptiodDefault, setUseStreamManagementResumption, setUseStreamManagementResumptionDefault, setWriter, shutdown, streamWasResumed, throwAlreadyConnectedExceptionIfAppropriate, throwAlreadyLoggedInExceptionIfAppropriate, throwNotConnectedExceptionIfAppropriate
-
Methods inherited from class org.jivesoftware.smack.AbstractXMPPConnection
addAsyncStanzaListener, addConnectionListener, addOneTimeSyncCallback, addPacketInterceptor, addPacketListener, addPacketSendingListener, addSyncStanzaListener, asyncGo, bindResourceAndEstablishSession, callConnectionAuthenticatedListener, callConnectionClosedOnErrorListener, callConnectionConnectedListener, createPacketCollector, createPacketCollector, createPacketCollectorAndSend, createPacketCollectorAndSend, disconnect, finalize, firePacketSendingListeners, getConfiguration, getConnectionCounter, getConnectionCreationListeners, getConnectionLock, getFeature, getFromMode, getHost, getLastStanzaReceived, getPacketReplyTimeout, getParsingExceptionCallback, getPort, getSASLAuthentication, getServiceName, getStreamId, getUser, hasFeature, initDebugger, invokePacketCollectorsAndNotifyRecvListeners, isAnonymous, isAuthenticated, isConnected, notifyReconnection, parseAndProcessStanza, parseFeatures, populateHostAddresses, processPacket, registerIQRequestHandler, removeAsyncStanzaListener, removeConnectionListener, removePacketCollector, removePacketInterceptor, removePacketListener, removePacketSendingListener, removeSyncStanzaListener, schedule, sendIqWithResponseCallback, sendIqWithResponseCallback, sendIqWithResponseCallback, sendPacket, sendStanza, sendStanzaWithResponseCallback, sendStanzaWithResponseCallback, sendStanzaWithResponseCallback, setFromMode, setPacketReplyTimeout, setParsingExceptionCallback, setReplyToUnknownIq, setReplyToUnknownIqDefault, setWasAuthenticated, throwNotConnectedExceptionIfAppropriate, unregisterIQRequestHandler, unregisterIQRequestHandler
-
-
-
-
Field Detail
-
DEFAULT_PING_INTERVAL
public static final int DEFAULT_PING_INTERVAL
- See Also:
- Constant Field Values
-
DEFAULT_CONNECTION_TIMEOUT
public static final int DEFAULT_CONNECTION_TIMEOUT
- See Also:
- Constant Field Values
-
DEFAULT_PACKET_REPLY_TIMEOUT
public static final int DEFAULT_PACKET_REPLY_TIMEOUT
- See Also:
- Constant Field Values
-
-
Constructor Detail
-
JabberConnection
public JabberConnection(String name, CharSequence username, String password, String serviceName, boolean allowReconnection, Integer pingInterval)
-
JabberConnection
public JabberConnection(String name, XMPPTCPConnectionConfiguration config, boolean allowReconnection, long pingInterval)
-
JabberConnection
public JabberConnection(String name, CharSequence jid, String password, boolean allowReconnection, Integer pingInterval)
-
-
Method Detail
-
buildConfiguration
public static XMPPTCPConnectionConfiguration buildConfiguration(Map configuration)
Creates a jabber based on the configuration map provided Properties for configuring jabber connection NOTE THIS IS FOR ENDPOINT ONLY{ Key: replyServiceResponse, Type:
- Set to true if service response will return its object to the sender. Only String and Gstring will be returned. if you want to return marshalled object make sure to set useObjectConverter configuration to trueBoolean
}{ Key: useObjectConverter, Type:
- If service response is set to true. Objects will return as jsonBoolean
}
- Parameters:
name
- Jabber connection nameconfiguration
-{ Key: callbackHandler, Type:
- SeeCallbackHandler
}ConnectionConfiguration.Builder.setCallbackHandler(CallbackHandler)
{ compressionEnabled, Type:
- SeeBoolean
}XMPPTCPConnectionConfiguration.Builder.setCompressionEnabled(boolean)
{ connectTimeout, Type:
- SeeInteger
DEFAULT 50seconds }XMPPTCPConnectionConfiguration.Builder.setConnectTimeout(int)
{ sslContext, Type:
- SeeSSLContext
}ConnectionConfiguration.Builder.setCustomSSLContext(SSLContext)
{ debuggerEnabled, Type:
- SeeBoolean
}ConnectionConfiguration.Builder.setDebuggerEnabled(boolean)
{ enabledSSLCiphers, Type:
- SeeString
orList
}ConnectionConfiguration.Builder.setEnabledSSLCiphers(String[])
{ enabledSSLProtocols, Type:
- SeeString
orList
}ConnectionConfiguration.Builder.setEnabledSSLProtocols(String[])
{ host, Type:
- SeeString
}ConnectionConfiguration.Builder.setHost(String)
{ hostnameVerifier, Type:
- SeeHostnameVerifier
}ConnectionConfiguration.Builder.setHostnameVerifier(HostnameVerifier)
{ keystorePath, Type:
- SeeString
}ConnectionConfiguration.Builder.setKeystorePath(String)
{ keystoreType, Type:
- SeeString
}ConnectionConfiguration.Builder.setKeystoreType(String)
{ legacySessionDisabled, Type:
- SeeBoolean
}ConnectionConfiguration.Builder.setLegacySessionDisabled(boolean)
{ pkcs11Library, Type:
- SeeString
}ConnectionConfiguration.Builder.setPKCS11Library(String)
{ port, Type:
- SeeInteger
}ConnectionConfiguration.Builder.setPort(int)
{ proxyInfo, Type:
- SeeProxyInfo
}ConnectionConfiguration.Builder.setProxyInfo(ProxyInfo)
{ resource, Type:
- SeeString
}ConnectionConfiguration.Builder.setResource(String)
{ securityMode, Type:
- SeeConnectionConfiguration.SecurityMode
orString
}ConnectionConfiguration.Builder.setSecurityMode(SecurityMode)
{ sendPresence, Type:
- SeeBoolean
}ConnectionConfiguration.Builder.setSendPresence(boolean)
{ serviceName, Type:
- SeeString
}ConnectionConfiguration.Builder.setServiceName(String)
{ socketFactory, Type:
- SeeSocketFactory
}ConnectionConfiguration.Builder.setSocketFactory(SocketFactory)
{ username, Type:
- Username of your jabber accountString
}{ password, Type:
- password of jabber accountBoolean
}{ packetReplyTimeout, Type:
- SeeLong
DEFAULT 10seconds }AbstractXMPPConnection.setPacketReplyTimeout(long)
{ pingInterval, Type:
- SeeInteger
DEFAULT 20seconds }PingManager.setPingInterval(int)
{ allowEmptyOrNullUsernames, Type:
- SeeBoolean
}ConnectionConfiguration.Builder.allowEmptyOrNullUsernames()
{ allowReconnection, Type:
- EnablesBoolean
DEFAULT: true }ReconnectionManager
-
connect
public JabberConnection connect() throws SmackException, IOException, XMPPException
- Overrides:
connect
in classAbstractXMPPConnection
- Throws:
SmackException
IOException
XMPPException
-
connectInternal
protected void connectInternal() throws SmackException, IOException, XMPPException
- Overrides:
connectInternal
in classXMPPTCPConnection
- Throws:
SmackException
IOException
XMPPException
-
login
public void login() throws XMPPException, SmackException, IOException
- Overrides:
login
in classAbstractXMPPConnection
- Throws:
XMPPException
SmackException
IOException
-
login
public void login(CharSequence username, String password) throws XMPPException, SmackException, IOException
- Overrides:
login
in classAbstractXMPPConnection
- Throws:
XMPPException
SmackException
IOException
-
login
public void login(CharSequence username, String password, String resource) throws XMPPException, SmackException, IOException
- Overrides:
login
in classAbstractXMPPConnection
- Throws:
XMPPException
SmackException
IOException
-
getName
public String getName()
-
setName
public void setName(io.toro.martini.endpoint.Endpoint endpoint)
-
setName
public void setName(String name)
-
isAllowReconnection
public boolean isAllowReconnection()
-
getPingInterval
public Integer getPingInterval()
-
getUsers
public Set<RosterEntry> getUsers()
-
sendMessage
public void sendMessage(String jid, String message) throws SmackException.NotConnectedException
-
sendMessage
public void sendMessage(String jid, Message message) throws SmackException.NotConnectedException
-
addChatListener
public void addChatListener(ChatManagerListener listener)
-
disconnect
public void disconnect()
- Overrides:
disconnect
in classAbstractXMPPConnection
-
instantShutdown
public void instantShutdown()
- Overrides:
instantShutdown
in classXMPPTCPConnection
-
close
public void close()
- Specified by:
close
in interfaceAutoCloseable
-
-