-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Please, remove pubnub-matchmaking-kotlinOld module after you rewrite logic that is inside of it.
- Loading branch information
1 parent
46494e3
commit aed77cb
Showing
20 changed files
with
678 additions
and
3 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -39,7 +39,7 @@ POM_DEVELOPER_NAME=PubNub | |
POM_DEVELOPER_URL=[email protected] | ||
|
||
IOS_SIMULATOR_ID=iPhone 15 Pro | ||
#SWIFT_PATH=../swift | ||
#SWIFT_PATH=../swift # swift jest lokalny do kotlina repo | ||
|
||
ENABLE_TARGET_JS=true | ||
ENABLE_TARGET_IOS_OTHER=false | ||
|
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
1 change: 1 addition & 0 deletions
1
...tlin-impl/src/integrationTest/kotlin/com/pubnub/api/integration/ObjectsIntegrationTest.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
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 @@ | ||
plugins { | ||
alias(libs.plugins.benmanes.versions) | ||
id("pubnub.kotlin-library") | ||
id("pubnub.dokka") | ||
} | ||
|
||
dependencies { | ||
api(project(":pubnub-matchmaking-kotlin:pubnub-matchmaking-kotlin-api")) | ||
implementation(project(":pubnub-matchmaking-kotlin:pubnub-matchmaking-kotlin-impl")) | ||
} |
Empty file.
58 changes: 58 additions & 0 deletions
58
pubnub-matchmaking-kotlin/pubnub-matchmaking-kotlin-api/build.gradle.kts
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,58 @@ | ||
import com.pubnub.gradle.enableAnyIosTarget // why ENABLE_TARGET_IOS_OTHER=false | ||
import com.pubnub.gradle.enableJsTarget | ||
|
||
plugins { | ||
alias(libs.plugins.benmanes.versions) | ||
id("pubnub.shared") | ||
id("pubnub.dokka") | ||
id("pubnub.multiplatform") // adds plugin to enables KMP | ||
id("pubnub.ios-simulator-test") // todo what is this -> do odpalania testów na symulatorze ios | ||
} | ||
|
||
kotlin { | ||
sourceSets { | ||
val commonMain by getting { | ||
dependencies { | ||
api(project(":pubnub-kotlin:pubnub-kotlin-api")) | ||
// todo do sprawdzania na projekcie z niższym kotlinem wymuszając niższa wersję odpowiednią komenda | ||
implementation(libs.kotlinx.atomicfu) // todo do we need atomic functionality w kotlinie 2.1.2 to będzie w standart library. Przy major release | ||
} | ||
} | ||
val jvmMain by getting { | ||
dependencies { | ||
api(libs.retrofit2) | ||
api(libs.okhttp) | ||
api(libs.okhttp.logging) | ||
api(libs.gson) | ||
implementation(libs.slf4j) | ||
} | ||
} | ||
if (enableAnyIosTarget) { | ||
val appleMain by getting { | ||
dependencies { | ||
|
||
} | ||
} | ||
} | ||
|
||
if (enableJsTarget) { | ||
val jsMain by getting { | ||
dependencies { | ||
|
||
} | ||
} | ||
} | ||
|
||
val commonTest by getting { | ||
dependencies { | ||
// implementation(project(":pubnub-kotlin:pubnub-kotlin-test")) // todo not needed for now | ||
implementation(kotlin("test")) | ||
implementation(libs.coroutines.test) // used to implement await | ||
} | ||
} | ||
|
||
|
||
|
||
} | ||
|
||
} |
65 changes: 65 additions & 0 deletions
65
...pubnub-matchmaking-kotlin-api/src/commonMain/kotlin/com/pubnub/matchmaking/Matchmaking.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,65 @@ | ||
package com.pubnub.matchmaking | ||
|
||
import com.pubnub.api.models.consumer.objects.PNKey | ||
import com.pubnub.api.models.consumer.objects.PNPage | ||
import com.pubnub.api.models.consumer.objects.PNSortKey | ||
import com.pubnub.kmp.PNFuture | ||
import com.pubnub.matchmaking.entities.GetUsersResponse | ||
import com.pubnub.matchmaking.entities.MatchmakingCallback | ||
import com.pubnub.matchmaking.entities.MatchmakingStatus | ||
|
||
interface Matchmaking { | ||
fun createUser( | ||
id: String, | ||
name: String? = null, | ||
externalId: String? = null, | ||
profileUrl: String? = null, | ||
email: String? = null, | ||
custom: Any? = null, | ||
status: String? = null, | ||
type: String? = null, | ||
): PNFuture<User> | ||
|
||
fun getUser(userId: String): PNFuture<User> | ||
|
||
/** | ||
* Returns a paginated list of all users and their details | ||
* | ||
* @param filter Expression used to filter the results. Returns only these users whose properties satisfy the | ||
* given expression are returned. The filtering language is defined in [documentation](https://www.pubnub.com/docs/general/metadata/filtering). | ||
* @param sort A collection to specify the sort order. Available options are id, name, and updated. Use asc or desc | ||
* @param limit Number of objects to return in response. The default (and maximum) value is 100. | ||
* @param page Object used for pagination to define which previous or next result page you want to fetch. | ||
* | ||
* @return [PNFuture] containing a set of users with pagination information (next, prev, total). | ||
*/ | ||
fun getUsers( | ||
filter: String? = null, | ||
sort: Collection<PNSortKey<PNKey>> = listOf(), | ||
limit: Int? = null, | ||
page: PNPage? = null, | ||
): GetUsersResponse | ||
|
||
fun updateUser( | ||
id: String, | ||
// TODO change nulls to Optionals when there is support. In Kotlin SDK there should be possibility to handle PatchValue | ||
name: String? = null, | ||
externalId: String? = null, | ||
profileUrl: String? = null, | ||
email: String? = null, | ||
custom: Any? = null, // todo when KMP use CustomObject? | ||
status: String? = null, | ||
type: String? = null, | ||
): PNFuture<User> | ||
|
||
fun deleteUser(id: String, soft: Boolean = false): PNFuture<User?> | ||
|
||
fun findMatch(userId: String, callback: MatchmakingCallback): PNFuture<String> | ||
|
||
fun getMatchStatus(userId: String): com.pubnub.matchmaking.entities.MatchmakingStatus | ||
|
||
fun cancelMatchmaking(userId: String): PNFuture<Unit> | ||
|
||
// todo implement | ||
fun addMissingUserToMatch(userId: String): PNFuture<Unit> | ||
} |
70 changes: 70 additions & 0 deletions
70
...kotlin/pubnub-matchmaking-kotlin-api/src/commonMain/kotlin/com/pubnub/matchmaking/User.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,70 @@ | ||
package com.pubnub.matchmaking | ||
|
||
import com.pubnub.kmp.PNFuture | ||
import com.pubnub.matchmaking.Matchmaking | ||
|
||
//todo add kdoc | ||
interface User { | ||
val matchmaking: Matchmaking | ||
val id: String | ||
val name: String? | ||
val externalId: String? | ||
val profileUrl: String? | ||
val email: String | ||
val custom: Map<String, Any?>? | ||
val status: String? | ||
val type: String? | ||
val updated: String? | ||
val eTag: String? | ||
|
||
fun update( | ||
name: String? = null, | ||
externalId: String? = null, | ||
profileUrl: String? = null, | ||
email: String? = null, | ||
custom: Any? = null, // todo when KMP use CustomObject? | ||
status: String? = null, | ||
type: String? = null, | ||
): PNFuture<User> | ||
|
||
fun update( | ||
updateAction: UpdatableValues.( | ||
user: User | ||
) -> Unit | ||
): PNFuture<User> | ||
|
||
fun delete(soft: Boolean = false): PNFuture<User?> | ||
|
||
class UpdatableValues( | ||
/** | ||
* The new value for [User.name]. | ||
*/ | ||
var name: String? = null, | ||
/** | ||
* The new value for [User.externalId]. | ||
*/ | ||
var externalId: String? = null, | ||
/** | ||
* The new value for [User.profileUrl]. | ||
*/ | ||
var profileUrl: String? = null, | ||
/** | ||
* The new value for [User.email]. | ||
*/ | ||
var email: String? = null, | ||
/** | ||
* The new value for [User.custom]. | ||
*/ | ||
var custom: Any? = null, // todo when KMP use CustomObject? | ||
/** | ||
* The new value for [User.status]. | ||
*/ | ||
var status: String? = null, | ||
/** | ||
* The new value for [User.type]. | ||
*/ | ||
var type: String? = null, | ||
) | ||
|
||
companion object | ||
} |
11 changes: 11 additions & 0 deletions
11
...king-kotlin-api/src/commonMain/kotlin/com/pubnub/matchmaking/entities/GetUsersResponse.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,11 @@ | ||
package com.pubnub.matchmaking.entities | ||
|
||
import com.pubnub.api.models.consumer.objects.PNPage | ||
import com.pubnub.matchmaking.User | ||
|
||
class GetUsersResponse( | ||
val users: List<User>, | ||
val next: PNPage.PNNext?, | ||
val prev: PNPage.PNPrev?, | ||
val total: Int, | ||
) |
7 changes: 7 additions & 0 deletions
7
...g-kotlin-api/src/commonMain/kotlin/com/pubnub/matchmaking/entities/MatchmakingCallback.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,7 @@ | ||
package com.pubnub.matchmaking.entities | ||
|
||
interface MatchmakingCallback { | ||
fun onMatchFound(match: MatchmakingGroup?) | ||
fun onMatchmakingFailed(reason: String?) | ||
fun onStatusChange(status: MatchmakingStatus?) | ||
} |
5 changes: 5 additions & 0 deletions
5
...king-kotlin-api/src/commonMain/kotlin/com/pubnub/matchmaking/entities/MatchmakingGroup.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,5 @@ | ||
package com.pubnub.matchmaking.entities | ||
|
||
import com.pubnub.matchmaking.User | ||
|
||
class MatchmakingGroup (val users: Set<User>) //todo currently we returns Set<User>. What about Set<userid> ? |
14 changes: 14 additions & 0 deletions
14
...ing-kotlin-api/src/commonMain/kotlin/com/pubnub/matchmaking/entities/MatchmakingStatus.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,14 @@ | ||
package com.pubnub.matchmaking.entities | ||
|
||
enum class MatchmakingStatus { | ||
IN_QUEUE, | ||
MATCHMAKING_STARTED, | ||
RE_ADDED_TO_QUEUE, | ||
ALREADY_IN_QUEUE, | ||
MATCH_FOUND, | ||
CANCELLED, | ||
FAILED, | ||
|
||
INITIALLY_MATCHED, // todo do we need it, | ||
WAITING_FOR_CONFIRMATION// todo do we need it, | ||
} |
77 changes: 77 additions & 0 deletions
77
pubnub-matchmaking-kotlin/pubnub-matchmaking-kotlin-impl/build.gradle.kts
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,77 @@ | ||
@file:OptIn(ExperimentalKotlinGradlePluginApi::class) | ||
|
||
import com.pubnub.gradle.enableAnyIosTarget | ||
import com.pubnub.gradle.enableJsTarget | ||
import com.pubnub.gradle.tasks.GenerateVersionTask | ||
import org.gradle.kotlin.dsl.register | ||
import org.jetbrains.kotlin.gradle.ExperimentalKotlinGradlePluginApi | ||
import org.jetbrains.kotlin.gradle.plugin.cocoapods.CocoapodsExtension | ||
|
||
plugins { | ||
alias(libs.plugins.kotlinx.atomicfu) // todo do we need lib for atomic operations | ||
id("pubnub.ios-simulator-test") // start x-code ios simulator before ios test run | ||
id("pubnub.shared") | ||
id("pubnub.dokka") | ||
id("pubnub.multiplatform") | ||
// alias(libs.plugins.mokkery) // todo downgrade version in libs.version.toml to be compatible with used kotlin version(2.0.21) | ||
} | ||
|
||
kotlin { | ||
sourceSets { | ||
val commonMain by getting { | ||
dependencies { | ||
implementation(project(":pubnub-matchmaking-kotlin:pubnub-matchmaking-kotlin-api")) | ||
implementation(project(":pubnub-kotlin:pubnub-kotlin-api")) | ||
implementation(libs.kotlinx.atomicfu) //todo this is needed for Service that simulates matchmaking REST api call | ||
implementation(libs.touchlab.kermit) | ||
api(libs.coroutines) // todo this is needed for Service that simulates matchmaking REST api call | ||
} | ||
} | ||
|
||
val commonTest by getting { | ||
dependencies { | ||
implementation(kotlin("test")) | ||
// implementation(project(":pubnub-chat-test")) | ||
} | ||
} | ||
|
||
val jvmMain by getting { | ||
dependencies { | ||
// implementation(project(":pubnub-kotlin")) //todo it shouldn't be required but because of some error might be | ||
implementation(kotlin("test-junit")) | ||
} | ||
} | ||
|
||
if (enableJsTarget) { | ||
val jsTest by getting { | ||
dependencies { | ||
implementation(kotlin("test-js")) // to jest potrzebne bo testy KMP na targecie JS nie działały, mimo, że powinny | ||
} | ||
} | ||
} | ||
} | ||
|
||
if (enableAnyIosTarget) { | ||
(this as ExtensionAware).extensions.configure<CocoapodsExtension> { | ||
summary = "Some description for a Kotlin/Native module" | ||
homepage = "Link to a Kotlin/Native module homepage" | ||
} | ||
} | ||
} | ||
|
||
val generateVersion = | ||
tasks.register<GenerateVersionTask>("generateVersion") { | ||
fileName.set("MatchmakingVersion") | ||
packageName.set("com.pubnub.matchmaking.internal") | ||
constName.set("PUBNUB_MATCHMAKING_VERSION") | ||
version.set(providers.gradleProperty("VERSION_NAME")) | ||
outputDirectory.set( | ||
layout.buildDirectory.map { | ||
it.dir("generated/sources/generateVersion") | ||
}, | ||
) | ||
} | ||
|
||
kotlin.sourceSets.getByName("commonMain").kotlin.srcDir(generateVersion) | ||
|
||
|
Oops, something went wrong.