-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
10 changed files
with
119 additions
and
18 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<manifest xmlns:android="http://schemas.android.com/apk/res/android"> | ||
<uses-permission android:name="android.permission.INTERNET"/> | ||
</manifest> |
10 changes: 10 additions & 0 deletions
10
library/src/appleMain/kotlin/com/tidal/networktime/internal/HttpClientFactory.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,10 @@ | ||
package com.tidal.networktime.internal | ||
|
||
import io.ktor.client.HttpClient | ||
import io.ktor.client.HttpClientConfig | ||
import io.ktor.client.engine.darwin.Darwin | ||
|
||
internal actual class HttpClientFactory { | ||
|
||
actual operator fun invoke(config: HttpClientConfig<*>.() -> Unit) = HttpClient(Darwin, config) | ||
} |
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
9 changes: 9 additions & 0 deletions
9
library/src/commonMain/kotlin/com/tidal/networktime/internal/HttpClientFactory.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,9 @@ | ||
package com.tidal.networktime.internal | ||
|
||
import io.ktor.client.HttpClient | ||
import io.ktor.client.HttpClientConfig | ||
|
||
internal expect class HttpClientFactory() { | ||
|
||
operator fun invoke(config: HttpClientConfig<*>.() -> Unit = {}): HttpClient | ||
} |
24 changes: 24 additions & 0 deletions
24
library/src/commonMain/kotlin/com/tidal/networktime/internal/PlatformAgnosticSNTPClient.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,24 @@ | ||
package com.tidal.networktime.internal | ||
|
||
import com.tidal.networktime.NTPServer | ||
import com.tidal.networktime.ReadableClock | ||
import io.ktor.client.HttpClient | ||
import kotlinx.coroutines.CoroutineScope | ||
import kotlin.time.Duration | ||
import kotlin.time.Duration.Companion.seconds | ||
|
||
internal class PlatformAgnosticSNTPClient( | ||
val ntpServers: Array<out NTPServer>, | ||
val referenceClock: ReadableClock, | ||
val coroutineScope: CoroutineScope, | ||
val synchronizationInterval: Duration = 64.seconds, | ||
httpClientFactory: HttpClientFactory = HttpClientFactory(), | ||
) { | ||
val synchronizedEpochTime: Duration? | ||
get() = TODO("Get the time") | ||
private val httpClient = httpClientFactory() | ||
|
||
fun startSynchronization(): Unit = TODO("Start or return") | ||
|
||
fun stopSynchronization(): Unit = TODO("Stop or return") | ||
} |
10 changes: 10 additions & 0 deletions
10
library/src/jsMain/kotlin/com/tidal/networktime/internal/HttpClientFactory.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,10 @@ | ||
package com.tidal.networktime.internal | ||
|
||
import io.ktor.client.HttpClient | ||
import io.ktor.client.HttpClientConfig | ||
import io.ktor.client.engine.js.Js | ||
|
||
internal actual class HttpClientFactory { | ||
|
||
actual operator fun invoke(config: HttpClientConfig<*>.() -> Unit) = HttpClient(Js, config) | ||
} |
10 changes: 10 additions & 0 deletions
10
library/src/jvmMain/kotlin/com/tidal/networktime/internal/HttpClientFactory.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,10 @@ | ||
package com.tidal.networktime.internal | ||
|
||
import io.ktor.client.HttpClient | ||
import io.ktor.client.HttpClientConfig | ||
import io.ktor.client.engine.okhttp.OkHttp | ||
|
||
internal actual class HttpClientFactory { | ||
|
||
actual operator fun invoke(config: HttpClientConfig<*>.() -> Unit) = HttpClient(OkHttp, config) | ||
} |