@Inject
lateinit var socketManager: SocketManager
override fun onStart() {
super.onStart()
socketManager.socketConnect()
}
override fun onDestroy() {
super.onDestroy()
socketManager.socketDisconnect()
}
private fun socketOn() {
socketOff()
mSocket.on(TRANSACTION_EVENT, listeners.onTransactionsListening)
}
private fun socketOff() {
mSocket.off(TRANSACTION_EVENT)
}
var onTransactionsListening =
Emitter.Listener { args: Array<Any> ->
try {
val messageJson = JSONObject(args[0].toString())
Log.d(
TAG,
"SocketHelper setListening: json---- $messageJson"
)
} catch (e: JSONException) {
Log.d(
TAG,
"SocketHelper call: error " + e.message
)
e.printStackTrace()
}
}