mirror of
https://github.com/oxen-io/session-android.git
synced 2025-02-20 05:28:27 +00:00
job related
This commit is contained in:
parent
c3552bfded
commit
4c1df33059
@ -4,7 +4,7 @@ import kotlin.math.min
|
|||||||
import kotlin.math.pow
|
import kotlin.math.pow
|
||||||
import java.util.Timer
|
import java.util.Timer
|
||||||
|
|
||||||
import org.session.libsession.messaging.Configuration
|
import org.session.libsession.messaging.MessagingConfiguration
|
||||||
|
|
||||||
import org.session.libsignal.libsignal.logging.Log
|
import org.session.libsignal.libsignal.logging.Log
|
||||||
import kotlin.concurrent.schedule
|
import kotlin.concurrent.schedule
|
||||||
@ -25,7 +25,7 @@ class JobQueue : JobDelegate {
|
|||||||
|
|
||||||
fun addWithoutExecuting(job: Job) {
|
fun addWithoutExecuting(job: Job) {
|
||||||
job.id = System.currentTimeMillis().toString()
|
job.id = System.currentTimeMillis().toString()
|
||||||
Configuration.shared.storage.persist(job)
|
MessagingConfiguration.shared.storage.persist(job)
|
||||||
job.delegate = this
|
job.delegate = this
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -37,7 +37,7 @@ class JobQueue : JobDelegate {
|
|||||||
hasResumedPendingJobs = true
|
hasResumedPendingJobs = true
|
||||||
val allJobTypes = listOf(AttachmentDownloadJob.collection, AttachmentDownloadJob.collection, MessageReceiveJob.collection, MessageSendJob.collection, NotifyPNServerJob.collection)
|
val allJobTypes = listOf(AttachmentDownloadJob.collection, AttachmentDownloadJob.collection, MessageReceiveJob.collection, MessageSendJob.collection, NotifyPNServerJob.collection)
|
||||||
allJobTypes.forEach { type ->
|
allJobTypes.forEach { type ->
|
||||||
val allPendingJobs = Configuration.shared.storage.getAllPendingJobs(type)
|
val allPendingJobs = MessagingConfiguration.shared.storage.getAllPendingJobs(type)
|
||||||
allPendingJobs.sortedBy { it.id }.forEach { job ->
|
allPendingJobs.sortedBy { it.id }.forEach { job ->
|
||||||
Log.i("Jobs", "Resuming pending job of type: ${job::class.simpleName}.")
|
Log.i("Jobs", "Resuming pending job of type: ${job::class.simpleName}.")
|
||||||
job.delegate = this
|
job.delegate = this
|
||||||
@ -47,12 +47,12 @@ class JobQueue : JobDelegate {
|
|||||||
}
|
}
|
||||||
|
|
||||||
override fun handleJobSucceeded(job: Job) {
|
override fun handleJobSucceeded(job: Job) {
|
||||||
Configuration.shared.storage.markJobAsSucceeded(job)
|
MessagingConfiguration.shared.storage.markJobAsSucceeded(job)
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun handleJobFailed(job: Job, error: Exception) {
|
override fun handleJobFailed(job: Job, error: Exception) {
|
||||||
job.failureCount += 1
|
job.failureCount += 1
|
||||||
val storage = Configuration.shared.storage
|
val storage = MessagingConfiguration.shared.storage
|
||||||
if (storage.isJobCanceled(job)) { return Log.i("Jobs", "${job::class.simpleName} canceled.")}
|
if (storage.isJobCanceled(job)) { return Log.i("Jobs", "${job::class.simpleName} canceled.")}
|
||||||
storage.persist(job)
|
storage.persist(job)
|
||||||
if (job.failureCount == job.maxFailureCount) {
|
if (job.failureCount == job.maxFailureCount) {
|
||||||
@ -69,7 +69,7 @@ class JobQueue : JobDelegate {
|
|||||||
|
|
||||||
override fun handleJobFailedPermanently(job: Job, error: Exception) {
|
override fun handleJobFailedPermanently(job: Job, error: Exception) {
|
||||||
job.failureCount += 1
|
job.failureCount += 1
|
||||||
val storage = Configuration.shared.storage
|
val storage = MessagingConfiguration.shared.storage
|
||||||
storage.persist(job)
|
storage.persist(job)
|
||||||
storage.markJobAsFailed(job)
|
storage.markJobAsFailed(job)
|
||||||
}
|
}
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
package org.session.libsession.messaging.jobs
|
package org.session.libsession.messaging.jobs
|
||||||
|
|
||||||
class MessageReceiveJob : Job {
|
class MessageReceiveJob(val data: ByteArray, val isBackgroundPoll: Boolean, val openGroupMessageServerID: Long? = null, val openGroupID: String? = null) : Job {
|
||||||
override var delegate: JobDelegate? = null
|
override var delegate: JobDelegate? = null
|
||||||
override var id: String? = null
|
override var id: String? = null
|
||||||
override var failureCount: Int = 0
|
override var failureCount: Int = 0
|
||||||
|
Loading…
x
Reference in New Issue
Block a user