-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #778 from ably/feature/start-and-stop-ably-connection
Start and stop the Ably connection manually depending on the number of added trackables
- Loading branch information
Showing
28 changed files
with
404 additions
and
38 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
This file contains 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
28 changes: 28 additions & 0 deletions
28
publishing-sdk/src/main/java/com/ably/tracking/publisher/PublisherState.kt
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
package com.ably.tracking.publisher | ||
|
||
enum class PublisherState { | ||
/** | ||
* The publisher is created but has no connection to Ably. | ||
*/ | ||
IDLE, | ||
|
||
/** | ||
* The publisher is trying to connect to Ably. | ||
*/ | ||
CONNECTING, | ||
|
||
/** | ||
* The publisher is connected to Ably. | ||
*/ | ||
CONNECTED, | ||
|
||
/** | ||
* The publisher is trying to disconnect from Ably. | ||
*/ | ||
DISCONNECTING, | ||
|
||
/** | ||
* The publisher is stopped and should not be used anymore. | ||
*/ | ||
STOPPED | ||
} |
This file contains 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
This file contains 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
This file contains 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
16 changes: 16 additions & 0 deletions
16
...com/ably/tracking/publisher/workerqueue/resulthandlers/AddTrackableFailedResultHandler.kt
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
package com.ably.tracking.publisher.workerqueue.resulthandlers | ||
|
||
import com.ably.tracking.publisher.workerqueue.WorkerFactory | ||
import com.ably.tracking.publisher.workerqueue.WorkerParams | ||
import com.ably.tracking.publisher.workerqueue.results.AddTrackableFailedWorkResult | ||
import com.ably.tracking.publisher.workerqueue.workers.Worker | ||
|
||
internal class AddTrackableFailedResultHandler( | ||
private val workerFactory: WorkerFactory | ||
) : WorkResultHandler<AddTrackableFailedWorkResult> { | ||
override fun handle(workResult: AddTrackableFailedWorkResult): Worker? = | ||
when (workResult) { | ||
AddTrackableFailedWorkResult.StopConnectionCompleted -> | ||
workerFactory.createWorker(WorkerParams.StoppingConnectionFinished) | ||
} | ||
} |
This file contains 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
16 changes: 16 additions & 0 deletions
16
.../com/ably/tracking/publisher/workerqueue/resulthandlers/DisconnectSuccessResultHandler.kt
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
package com.ably.tracking.publisher.workerqueue.resulthandlers | ||
|
||
import com.ably.tracking.publisher.workerqueue.WorkerFactory | ||
import com.ably.tracking.publisher.workerqueue.WorkerParams | ||
import com.ably.tracking.publisher.workerqueue.results.DisconnectSuccessWorkResult | ||
import com.ably.tracking.publisher.workerqueue.workers.Worker | ||
|
||
internal class DisconnectSuccessResultHandler( | ||
private val workerFactory: WorkerFactory | ||
) : WorkResultHandler<DisconnectSuccessWorkResult> { | ||
override fun handle(workResult: DisconnectSuccessWorkResult): Worker? = | ||
when (workResult) { | ||
DisconnectSuccessWorkResult.StopConnectionCompleted -> | ||
workerFactory.createWorker(WorkerParams.StoppingConnectionFinished) | ||
} | ||
} |
16 changes: 16 additions & 0 deletions
16
...y/tracking/publisher/workerqueue/resulthandlers/TrackableRemovalRequestedResultHandler.kt
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
package com.ably.tracking.publisher.workerqueue.resulthandlers | ||
|
||
import com.ably.tracking.publisher.workerqueue.WorkerFactory | ||
import com.ably.tracking.publisher.workerqueue.WorkerParams | ||
import com.ably.tracking.publisher.workerqueue.results.TrackableRemovalRequestedWorkResult | ||
import com.ably.tracking.publisher.workerqueue.workers.Worker | ||
|
||
internal class TrackableRemovalRequestedResultHandler( | ||
private val workerFactory: WorkerFactory | ||
) : WorkResultHandler<TrackableRemovalRequestedWorkResult> { | ||
override fun handle(workResult: TrackableRemovalRequestedWorkResult): Worker? = | ||
when (workResult) { | ||
TrackableRemovalRequestedWorkResult.StopConnectionCompleted -> | ||
workerFactory.createWorker(WorkerParams.StoppingConnectionFinished) | ||
} | ||
} |
This file contains 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
Oops, something went wrong.