Created
January 17, 2018 08:07
-
-
Save dbh4ck/20f1ccba3214da129983c8bbabbb1084 to your computer and use it in GitHub Desktop.
Singleton class For Kotlin Android SmackXMPP Connection Sample
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| package com.db.chatpluskotlin.xmpp | |
| import org.jivesoftware.smack.AbstractXMPPConnection | |
| /** | |
| * Created by DB on 23-12-2017. | |
| */ | |
| public object XMPPLogic { | |
| var connection: AbstractXMPPConnection? = null | |
| var ourInstance: XMPPLogic? = null | |
| @Synchronized | |
| fun getInstance(): XMPPLogic { | |
| var xMPPLogic: XMPPLogic? = null | |
| synchronized(XMPPLogic::class.java) { | |
| if (ourInstance == null) { | |
| ourInstance = XMPPLogic | |
| } | |
| xMPPLogic = ourInstance as XMPPLogic | |
| } | |
| return xMPPLogic!! | |
| } | |
| fun getAConnection(): AbstractXMPPConnection? { | |
| return XMPPLogic.connection | |
| } | |
| fun setAConnection(connection: AbstractXMPPConnection) { | |
| XMPPLogic.connection = connection | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment