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 intDEFAULT_CONNECTION_TIMEOUTstatic intDEFAULT_PACKET_REPLY_TIMEOUTstatic intDEFAULT_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 voidaddChatListener(ChatManagerListener listener)static XMPPTCPConnectionConfigurationbuildConfiguration(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}voidclose()JabberConnectionconnect()protected voidconnectInternal()voiddisconnect()StringgetName()IntegergetPingInterval()Set<RosterEntry>getUsers()voidinstantShutdown()booleanisAllowReconnection()voidlogin()voidlogin(CharSequence username, String password)voidlogin(CharSequence username, String password, String resource)voidsendMessage(String jid, String message)voidsendMessage(String jid, Message message)voidsetName(io.toro.martini.endpoint.Endpoint endpoint)voidsetName(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:- SeeIntegerDEFAULT 50seconds }XMPPTCPConnectionConfiguration.Builder.setConnectTimeout(int){ sslContext, Type:- SeeSSLContext}ConnectionConfiguration.Builder.setCustomSSLContext(SSLContext){ debuggerEnabled, Type:- SeeBoolean}ConnectionConfiguration.Builder.setDebuggerEnabled(boolean){ enabledSSLCiphers, Type:- SeeStringorList}ConnectionConfiguration.Builder.setEnabledSSLCiphers(String[]){ enabledSSLProtocols, Type:- SeeStringorList}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.SecurityModeorString}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:- SeeLongDEFAULT 10seconds }AbstractXMPPConnection.setPacketReplyTimeout(long){ pingInterval, Type:- SeeIntegerDEFAULT 20seconds }PingManager.setPingInterval(int){ allowEmptyOrNullUsernames, Type:- SeeBoolean}ConnectionConfiguration.Builder.allowEmptyOrNullUsernames(){ allowReconnection, Type:- EnablesBooleanDEFAULT: true }ReconnectionManager
-
connect
public JabberConnection connect() throws SmackException, IOException, XMPPException
- Overrides:
connectin classAbstractXMPPConnection- Throws:
SmackExceptionIOExceptionXMPPException
-
connectInternal
protected void connectInternal() throws SmackException, IOException, XMPPException- Overrides:
connectInternalin classXMPPTCPConnection- Throws:
SmackExceptionIOExceptionXMPPException
-
login
public void login() throws XMPPException, SmackException, IOException- Overrides:
loginin classAbstractXMPPConnection- Throws:
XMPPExceptionSmackExceptionIOException
-
login
public void login(CharSequence username, String password) throws XMPPException, SmackException, IOException
- Overrides:
loginin classAbstractXMPPConnection- Throws:
XMPPExceptionSmackExceptionIOException
-
login
public void login(CharSequence username, String password, String resource) throws XMPPException, SmackException, IOException
- Overrides:
loginin classAbstractXMPPConnection- Throws:
XMPPExceptionSmackExceptionIOException
-
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:
disconnectin classAbstractXMPPConnection
-
instantShutdown
public void instantShutdown()
- Overrides:
instantShutdownin classXMPPTCPConnection
-
close
public void close()
- Specified by:
closein interfaceAutoCloseable
-
-