diff --git a/build-logic/gradle-plugins/src/main/kotlin/com/pubnub/gradle/PubNubKotlinMultiplatformPlugin.kt b/build-logic/gradle-plugins/src/main/kotlin/com/pubnub/gradle/PubNubKotlinMultiplatformPlugin.kt index e1ed9f52f..fae6c68bf 100644 --- a/build-logic/gradle-plugins/src/main/kotlin/com/pubnub/gradle/PubNubKotlinMultiplatformPlugin.kt +++ b/build-logic/gradle-plugins/src/main/kotlin/com/pubnub/gradle/PubNubKotlinMultiplatformPlugin.kt @@ -5,10 +5,13 @@ import org.gradle.api.Project import org.gradle.api.plugins.ExtensionAware import org.gradle.kotlin.dsl.apply import org.gradle.kotlin.dsl.configure +import org.gradle.kotlin.dsl.creating +import org.gradle.kotlin.dsl.getting +import org.gradle.kotlin.dsl.provideDelegate import org.gradle.kotlin.dsl.withType -import org.jetbrains.dokka.DokkaDefaults.moduleName import org.jetbrains.kotlin.gradle.dsl.KotlinMultiplatformExtension import org.jetbrains.kotlin.gradle.plugin.KotlinMultiplatformPluginWrapper +import org.jetbrains.kotlin.gradle.plugin.KotlinSourceSetContainer import org.jetbrains.kotlin.gradle.plugin.cocoapods.CocoapodsExtension import org.jetbrains.kotlin.gradle.plugin.cocoapods.KotlinCocoapodsPlugin import org.jetbrains.kotlin.gradle.plugin.mpp.KotlinNativeTarget @@ -43,7 +46,6 @@ class PubNubKotlinMultiplatformPlugin : Plugin { listOf( iosArm64(), - // iosX64(), iosSimulatorArm64(), ).forEach { it.binaries { @@ -52,6 +54,22 @@ class PubNubKotlinMultiplatformPlugin : Plugin { } } } + applyDefaultHierarchyTemplate() + with (sourceSets) { + val commonMain = getByName("commonMain") + + val nonJvm = create("nonJvm") { + it.dependsOn(commonMain) + } + + val jsMain = getByName("jsMain") { + it.dependsOn(nonJvm) + } + + val iosMain = getByName("iosMain") { + it.dependsOn(nonJvm) + } + } (this as? ExtensionAware)?.extensions?.configure { ios.deploymentTarget = "14" diff --git a/pubnub-core/pubnub-core-api/build.gradle.kts b/pubnub-core/pubnub-core-api/build.gradle.kts index a350ba89b..23007352e 100644 --- a/pubnub-core/pubnub-core-api/build.gradle.kts +++ b/pubnub-core/pubnub-core-api/build.gradle.kts @@ -32,4 +32,3 @@ kotlin { } } } - diff --git a/pubnub-core/pubnub-core-api/config/ktlint/baseline.xml b/pubnub-core/pubnub-core-api/config/ktlint/baseline.xml index 1e346c7d2..981420778 100644 --- a/pubnub-core/pubnub-core-api/config/ktlint/baseline.xml +++ b/pubnub-core/pubnub-core-api/config/ktlint/baseline.xml @@ -1,6 +1,3 @@ - - - diff --git a/pubnub-core/pubnub-core-api/src/commonTest/kotlin/com/pubnub/kmp/JsonElementTest.kt b/pubnub-core/pubnub-core-api/src/commonTest/kotlin/com/pubnub/kmp/JsonElementTest.kt index 41346d10f..e63308b60 100644 --- a/pubnub-core/pubnub-core-api/src/commonTest/kotlin/com/pubnub/kmp/JsonElementTest.kt +++ b/pubnub-core/pubnub-core-api/src/commonTest/kotlin/com/pubnub/kmp/JsonElementTest.kt @@ -7,12 +7,11 @@ import kotlin.test.Test import kotlin.test.assertEquals class JsonElementTest { - @Test fun asList() { val list = listOf("abc", "def") - val jsonList = createJsonElement(list.map { createJsonElement(it) }) + val jsonList = createJsonElement(list) assertEquals(list, jsonList.asList()?.map { it.asString() }) } -} \ No newline at end of file +} diff --git a/pubnub-core/pubnub-core-api/src/iosMain/kotlin/com/pubnub/api/JsonElement.ios.kt b/pubnub-core/pubnub-core-api/src/iosMain/kotlin/com/pubnub/api/JsonElement.ios.kt index ea46b4a9d..c4695a845 100644 --- a/pubnub-core/pubnub-core-api/src/iosMain/kotlin/com/pubnub/api/JsonElement.ios.kt +++ b/pubnub-core/pubnub-core-api/src/iosMain/kotlin/com/pubnub/api/JsonElement.ios.kt @@ -35,7 +35,7 @@ actual abstract class JsonElement(val value: Any?) { } override fun toString(): String { - return "JSONElement(${value.toString()})" + return "JSONElement($value)" } } diff --git a/pubnub-kotlin/pubnub-kotlin-api/config/ktlint/baseline.xml b/pubnub-kotlin/pubnub-kotlin-api/config/ktlint/baseline.xml index ee5e6035a..7d091a9a8 100644 --- a/pubnub-kotlin/pubnub-kotlin-api/config/ktlint/baseline.xml +++ b/pubnub-kotlin/pubnub-kotlin-api/config/ktlint/baseline.xml @@ -75,7 +75,7 @@ - - + + diff --git a/pubnub-kotlin/pubnub-kotlin-api/src/commonMain/kotlin/com/pubnub/kmp/PubNub.kt b/pubnub-kotlin/pubnub-kotlin-api/src/commonMain/kotlin/com/pubnub/api/PubNub.kt similarity index 99% rename from pubnub-kotlin/pubnub-kotlin-api/src/commonMain/kotlin/com/pubnub/kmp/PubNub.kt rename to pubnub-kotlin/pubnub-kotlin-api/src/commonMain/kotlin/com/pubnub/api/PubNub.kt index 69a064570..d626c11de 100644 --- a/pubnub-kotlin/pubnub-kotlin-api/src/commonMain/kotlin/com/pubnub/kmp/PubNub.kt +++ b/pubnub-kotlin/pubnub-kotlin-api/src/commonMain/kotlin/com/pubnub/api/PubNub.kt @@ -1,4 +1,4 @@ -package com.pubnub.kmp +package com.pubnub.api import com.pubnub.api.callbacks.Listener import com.pubnub.api.endpoints.DeleteMessages @@ -71,8 +71,10 @@ import com.pubnub.api.v2.subscriptions.EmptyOptions import com.pubnub.api.v2.subscriptions.Subscription import com.pubnub.api.v2.subscriptions.SubscriptionOptions import com.pubnub.api.v2.subscriptions.SubscriptionSet +import com.pubnub.kmp.CustomObject +import com.pubnub.kmp.Uploadable -interface PubNub { +expect interface PubNub { val configuration: PNConfiguration fun addListener(listener: EventListener) diff --git a/pubnub-kotlin/pubnub-kotlin-api/src/commonMain/kotlin/com/pubnub/kmp/factories.kt b/pubnub-kotlin/pubnub-kotlin-api/src/commonMain/kotlin/com/pubnub/kmp/factories.kt index ca75391bd..c57dd3b12 100644 --- a/pubnub-kotlin/pubnub-kotlin-api/src/commonMain/kotlin/com/pubnub/kmp/factories.kt +++ b/pubnub-kotlin/pubnub-kotlin-api/src/commonMain/kotlin/com/pubnub/kmp/factories.kt @@ -1,5 +1,6 @@ package com.pubnub.kmp +import com.pubnub.api.PubNub import com.pubnub.api.models.consumer.PNStatus import com.pubnub.api.models.consumer.pubsub.PNMessageResult import com.pubnub.api.models.consumer.pubsub.PNPresenceEventResult diff --git a/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/PubNubImpl.kt b/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/PubNubImpl.kt index e79ebc97b..3d6c1a6d9 100644 --- a/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/PubNubImpl.kt +++ b/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/PubNubImpl.kt @@ -139,7 +139,6 @@ import com.pubnub.internal.entities.UserMetadataImpl import com.pubnub.internal.subscription.SubscriptionImpl import com.pubnub.internal.subscription.SubscriptionSetImpl import com.pubnub.kmp.CustomObject -import com.pubnub.kmp.PubNub import com.pubnub.kmp.Uploadable import kotlinx.cinterop.ExperimentalForeignApi diff --git a/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/v2/callbacks/EventListener.ios.kt b/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/v2/callbacks/EventListener.ios.kt index 183734c2d..fd0965f19 100644 --- a/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/v2/callbacks/EventListener.ios.kt +++ b/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/v2/callbacks/EventListener.ios.kt @@ -1,13 +1,13 @@ package com.pubnub.api.v2.callbacks import cocoapods.PubNubSwift.PubNubEventListenerObjC +import com.pubnub.api.PubNub import com.pubnub.api.models.consumer.pubsub.PNMessageResult import com.pubnub.api.models.consumer.pubsub.PNPresenceEventResult import com.pubnub.api.models.consumer.pubsub.PNSignalResult import com.pubnub.api.models.consumer.pubsub.files.PNFileEventResult import com.pubnub.api.models.consumer.pubsub.message_actions.PNMessageActionResult import com.pubnub.api.models.consumer.pubsub.objects.PNObjectEventResult -import com.pubnub.kmp.PubNub import kotlinx.cinterop.ExperimentalForeignApi /** diff --git a/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/v2/callbacks/StatusListener.ios.kt b/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/v2/callbacks/StatusListener.ios.kt index baf190dba..9723f6e24 100644 --- a/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/v2/callbacks/StatusListener.ios.kt +++ b/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/v2/callbacks/StatusListener.ios.kt @@ -1,9 +1,9 @@ package com.pubnub.api.v2.callbacks import cocoapods.PubNubSwift.PubNubStatusListenerObjC +import com.pubnub.api.PubNub import com.pubnub.api.callbacks.Listener import com.pubnub.api.models.consumer.PNStatus -import com.pubnub.kmp.PubNub import kotlinx.cinterop.ExperimentalForeignApi /** diff --git a/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/kmp/factories.ios.kt b/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/kmp/factories.ios.kt index 6d6897820..31c79bc1e 100644 --- a/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/kmp/factories.ios.kt +++ b/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/kmp/factories.ios.kt @@ -22,6 +22,7 @@ import cocoapods.PubNubSwift.PubNubSetMembershipResultObjC import cocoapods.PubNubSwift.PubNubSetUUIDMetadataResultObjC import cocoapods.PubNubSwift.PubNubStatusListenerObjC import com.pubnub.api.JsonElementImpl +import com.pubnub.api.PubNub import com.pubnub.api.PubNubException import com.pubnub.api.PubNubImpl import com.pubnub.api.enums.PNStatusCategory diff --git a/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/PubNubImpl.kt b/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/PubNubImpl.kt index 960c6382b..a58ba76e5 100644 --- a/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/PubNubImpl.kt +++ b/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/PubNubImpl.kt @@ -127,7 +127,6 @@ import com.pubnub.internal.v2.entities.ChannelImpl import com.pubnub.internal.v2.subscriptions.SubscriptionSetImpl import com.pubnub.kmp.CustomObject import com.pubnub.kmp.Optional -import com.pubnub.kmp.PubNub import com.pubnub.kmp.Uploadable import com.pubnub.kmp.createJsObject import com.pubnub.kmp.toJsMap diff --git a/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/kmp/factories.js.kt b/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/kmp/factories.js.kt index dcd6d45cd..312bf41c5 100644 --- a/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/kmp/factories.js.kt +++ b/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/kmp/factories.js.kt @@ -1,6 +1,7 @@ package com.pubnub.kmp import com.pubnub.api.JsonElementImpl +import com.pubnub.api.PubNub import com.pubnub.api.PubNubImpl import com.pubnub.api.enums.PNStatusCategory import com.pubnub.api.models.consumer.PNStatus diff --git a/pubnub-kotlin/pubnub-kotlin-api/src/jvmMain/kotlin/com/pubnub/api/PubNub.kt b/pubnub-kotlin/pubnub-kotlin-api/src/jvmMain/kotlin/com/pubnub/api/PubNub.kt index b751c202a..d4ff9b6c7 100644 --- a/pubnub-kotlin/pubnub-kotlin-api/src/jvmMain/kotlin/com/pubnub/api/PubNub.kt +++ b/pubnub-kotlin/pubnub-kotlin-api/src/jvmMain/kotlin/com/pubnub/api/PubNub.kt @@ -72,13 +72,13 @@ import com.pubnub.api.v2.entities.ChannelGroup import com.pubnub.api.v2.entities.ChannelMetadata import com.pubnub.api.v2.entities.UserMetadata import com.pubnub.api.v2.subscriptions.Subscription +import com.pubnub.api.v2.subscriptions.SubscriptionOptions import com.pubnub.api.v2.subscriptions.SubscriptionSet import com.pubnub.internal.BasePubNubImpl import com.pubnub.kmp.CustomObject import java.io.InputStream -interface PubNub : - com.pubnub.kmp.PubNub, +actual interface PubNub : BasePubNub, EventEmitter { companion object { @@ -131,7 +131,7 @@ interface PubNub : * Modifying the values in this configuration is not advised, as it may lead * to undefined behavior. */ - override val configuration: com.pubnub.api.v2.PNConfiguration + actual val configuration: com.pubnub.api.v2.PNConfiguration /** * Add a legacy listener for both client status and events. @@ -187,7 +187,7 @@ interface PubNub : * - If ttl isn't specified, then expiration of the message defaults * back to the expiry value for the key. */ - override fun publish( + actual fun publish( channel: String, message: Any, meta: Any?, @@ -227,7 +227,7 @@ interface PubNub : * - If ttl isn't specified, then expiration of the message defaults * back to the expiry value for the key. */ - override fun fire( + actual fun fire( channel: String, message: Any, meta: Any?, @@ -245,7 +245,7 @@ interface PubNub : * @param channel The channel which the signal will be sent to. * @param message The payload which will be serialized and sent. */ - override fun signal( + actual fun signal( channel: String, message: Any, ): Signal @@ -255,14 +255,14 @@ interface PubNub : * * @return A list of channels the client is currently subscribed to. */ - override fun getSubscribedChannels(): List + actual fun getSubscribedChannels(): List /** * Queries the local subscribe loop for channel groups currently in the mix. * * @return A list of channel groups the client is currently subscribed to. */ - override fun getSubscribedChannelGroups(): List + actual fun getSubscribedChannelGroups(): List /** * Enable push notifications on provided set of channels. @@ -276,7 +276,7 @@ interface PubNub : * @param topic Notifications topic name (usually it is bundle identifier of application for Apple platform). * Required only if pushType set to [PNPushType.APNS2]. */ - override fun addPushNotificationsOnChannels( + actual fun addPushNotificationsOnChannels( pushType: PNPushType, channels: List, deviceId: String, @@ -294,7 +294,7 @@ interface PubNub : * @param topic Notifications topic name (usually it is bundle identifier of application for Apple platform). * Required only if pushType set to [PNPushType.APNS2]. */ - override fun auditPushChannelProvisions( + actual fun auditPushChannelProvisions( pushType: PNPushType, deviceId: String, topic: String?, @@ -312,7 +312,7 @@ interface PubNub : * @param topic Notifications topic name (usually it is bundle identifier of application for Apple platform). * Required only if pushType set to [PNPushType.APNS2]. */ - override fun removePushNotificationsFromChannels( + actual fun removePushNotificationsFromChannels( pushType: PNPushType, channels: List, deviceId: String, @@ -330,7 +330,7 @@ interface PubNub : * @param topic Notifications topic name (usually it is bundle identifier of application for Apple platform). * Required only if pushType set to [PNPushType.APNS2]. */ - override fun removeAllPushNotificationsFromDeviceWithPushToken( + actual fun removeAllPushNotificationsFromDeviceWithPushToken( pushType: PNPushType, deviceId: String, topic: String?, @@ -473,7 +473,7 @@ interface PubNub : * @param includeMessageType Whether to include message type in response. * Defaults to `false`. */ - override fun fetchMessages( + actual fun fetchMessages( channels: List, page: PNBoundedPage, includeUUID: Boolean, @@ -495,7 +495,7 @@ interface PubNub : * @param start Timetoken delimiting the start of time slice (exclusive) to delete messages from. * @param end Time token delimiting the end of time slice (inclusive) to delete messages from. */ - override fun deleteMessages( + actual fun deleteMessages( channels: List, start: Long?, end: Long?, @@ -511,7 +511,7 @@ interface PubNub : * Specify a single timetoken to apply it to all channels. * Otherwise, the list of timetokens must be the same length as the list of channels. */ - override fun messageCounts( + actual fun messageCounts( channels: List, channelsTimetoken: List, ): MessageCounts @@ -529,7 +529,7 @@ interface PubNub : * @param includeUUIDs Whether the response should include UUIDs od connected clients. * Defaults to `true`. */ - override fun hereNow( + actual fun hereNow( channels: List, channelGroups: List, includeState: Boolean, @@ -542,7 +542,7 @@ interface PubNub : * @param uuid UUID of the user to get its current channel subscriptions. Defaults to the UUID of the client. * @see [PNConfiguration.uuid] */ - override fun whereNow(uuid: String): WhereNow + actual fun whereNow(uuid: String): WhereNow /** * Set state information specific to a subscriber UUID. @@ -589,7 +589,7 @@ interface PubNub : * When calling [PubNub.setPresenceState], be sure to supply an initialized JsonObject * or POJO which can be serialized to a JsonObject. */ - override fun setPresenceState( + actual fun setPresenceState( channels: List, channelGroups: List, state: Any, @@ -605,7 +605,7 @@ interface PubNub : * @param uuid UUID of the user to get the state from. Defaults to the UUID of the client. * @see [PNConfiguration.uuid] */ - override fun getPresenceState( + actual fun getPresenceState( channels: List, channelGroups: List, uuid: String, @@ -620,7 +620,7 @@ interface PubNub : * @param channels Channels to subscribe/unsubscribe. Either `channel` or [channelGroups] are required. * @param channelGroups Channel groups to subscribe/unsubscribe. Either `channelGroups` or [channels] are required. */ - override fun presence( + actual fun presence( channels: List, channelGroups: List, connected: Boolean, @@ -633,7 +633,7 @@ interface PubNub : * @param messageAction The message action object containing the message action's type, * value and the publish timetoken of the original message. */ - override fun addMessageAction( + actual fun addMessageAction( channel: String, messageAction: PNMessageAction, ): AddMessageAction @@ -645,7 +645,7 @@ interface PubNub : * @param messageTimetoken The publish timetoken of the original message. * @param actionTimetoken The publish timetoken of the message action to be removed. */ - override fun removeMessageAction( + actual fun removeMessageAction( channel: String, messageTimetoken: Long, actionTimetoken: Long, @@ -683,7 +683,7 @@ interface PubNub : * @param channel Channel to fetch message actions from. * @param page The paging object used for pagination. @see [PNBoundedPage] */ - override fun getMessageActions( + actual fun getMessageActions( channel: String, page: PNBoundedPage, ): GetMessageActions @@ -694,7 +694,7 @@ interface PubNub : * @param channels The channels to add to the channel group. * @param channelGroup The channel group to add the channels to. */ - override fun addChannelsToChannelGroup( + actual fun addChannelsToChannelGroup( channels: List, channelGroup: String, ): AddChannelChannelGroup @@ -704,7 +704,7 @@ interface PubNub : * * @param channelGroup Channel group to fetch the belonging channels. */ - override fun listChannelsForChannelGroup(channelGroup: String): AllChannelsChannelGroup + actual fun listChannelsForChannelGroup(channelGroup: String): AllChannelsChannelGroup /** * Removes channels from a channel group. @@ -712,7 +712,7 @@ interface PubNub : * @param channelGroup The channel group to remove channels from * @param channels The channels to remove from the channel group. */ - override fun removeChannelsFromChannelGroup( + actual fun removeChannelsFromChannelGroup( channels: List, channelGroup: String, ): RemoveChannelChannelGroup @@ -720,14 +720,14 @@ interface PubNub : /** * Lists all registered channel groups for the subscribe key. */ - override fun listAllChannelGroups(): ListAllChannelGroup + actual fun listAllChannelGroups(): ListAllChannelGroup /** * Removes the channel group. * * @param channelGroup The channel group to remove. */ - override fun deleteChannelGroup(channelGroup: String): DeleteChannelGroup + actual fun deleteChannelGroup(channelGroup: String): DeleteChannelGroup /** * This function establishes access permissions for PubNub Access Manager (PAM) by setting the `read` or `write` @@ -819,7 +819,7 @@ interface PubNub : * @param uuids List of all uuid grants */ - override fun grantToken( + actual fun grantToken( ttl: Int, meta: Any?, authorizedUUID: String?, @@ -857,12 +857,12 @@ interface PubNub : * * @param token Existing token with embedded permissions. */ - override fun revokeToken(token: String): RevokeToken + actual fun revokeToken(token: String): RevokeToken /** * Returns a 17 digit precision Unix epoch from the server. */ - override fun time(): Time + actual fun time(): Time /** * Returns a paginated list of Channel Metadata objects, optionally including the custom data object for each. @@ -882,7 +882,7 @@ interface PubNub : * Default is `false`. * @param includeCustom Include respective additional fields in the response. */ - override fun getAllChannelMetadata( + actual fun getAllChannelMetadata( limit: Int?, page: PNPage?, filter: String?, @@ -897,7 +897,7 @@ interface PubNub : * @param channel Channel name. * @param includeCustom Include respective additional fields in the response. */ - override fun getChannelMetadata( + actual fun getChannelMetadata( channel: String, includeCustom: Boolean, ): GetChannelMetadata @@ -911,7 +911,7 @@ interface PubNub : * @param custom Object with supported data types. * @param includeCustom Include respective additional fields in the response. */ - override fun setChannelMetadata( + actual fun setChannelMetadata( channel: String, name: String?, description: String?, @@ -926,7 +926,7 @@ interface PubNub : * * @param channel Channel name. */ - override fun removeChannelMetadata(channel: String): RemoveChannelMetadata + actual fun removeChannelMetadata(channel: String): RemoveChannelMetadata /** * Returns a paginated list of UUID Metadata objects, optionally including the custom data object for each. @@ -946,7 +946,7 @@ interface PubNub : * Default is `false`. * @param includeCustom Include respective additional fields in the response. */ - override fun getAllUUIDMetadata( + actual fun getAllUUIDMetadata( limit: Int?, page: PNPage?, filter: String?, @@ -961,7 +961,7 @@ interface PubNub : * @param uuid Unique user identifier. If not supplied then current user’s uuid is used. * @param includeCustom Include respective additional fields in the response. */ - override fun getUUIDMetadata( + actual fun getUUIDMetadata( uuid: String?, includeCustom: Boolean, ): GetUUIDMetadata @@ -977,7 +977,7 @@ interface PubNub : * @param custom Object with supported data types. * @param includeCustom Include respective additional fields in the response. */ - override fun setUUIDMetadata( + actual fun setUUIDMetadata( uuid: String?, name: String?, externalId: String?, @@ -994,7 +994,7 @@ interface PubNub : * * @param uuid Unique user identifier. If not supplied then current user’s uuid is used. */ - override fun removeUUIDMetadata(uuid: String?): RemoveUUIDMetadata + actual fun removeUUIDMetadata(uuid: String?): RemoveUUIDMetadata /** * The method returns a list of channel memberships for a user. This method doesn't return a user's subscriptions. @@ -1016,7 +1016,7 @@ interface PubNub : * @param includeCustom Include respective additional fields in the response. * @param includeChannelDetails Include custom fields for channels metadata. */ - override fun getMemberships( + actual fun getMemberships( uuid: String?, limit: Int?, page: PNPage?, @@ -1075,7 +1075,7 @@ interface PubNub : * @param includeCustom Include respective additional fields in the response. * @param includeChannelDetails Include custom fields for channels metadata. */ - override fun setMemberships( + actual fun setMemberships( channels: List, uuid: String?, limit: Int?, @@ -1109,7 +1109,7 @@ interface PubNub : * @param includeCustom Include respective additional fields in the response. * @param includeChannelDetails Include custom fields for channels metadata. */ - override fun removeMemberships( + actual fun removeMemberships( channels: List, uuid: String?, limit: Int?, @@ -1203,7 +1203,7 @@ interface PubNub : * @param includeCustom Include respective additional fields in the response. * @param includeUUIDDetails Include custom fields for UUIDs metadata. */ - override fun getChannelMembers( + actual fun getChannelMembers( channel: String, limit: Int?, page: PNPage?, @@ -1262,7 +1262,7 @@ interface PubNub : * @param includeCustom Include respective additional fields in the response. * @param includeUUIDDetails Include custom fields for UUIDs metadata. */ - override fun setChannelMembers( + actual fun setChannelMembers( channel: String, uuids: List, limit: Int?, @@ -1321,7 +1321,7 @@ interface PubNub : * @param includeCustom Include respective additional fields in the response. * @param includeUUIDDetails Include custom fields for UUIDs metadata. */ - override fun removeChannelMembers( + actual fun removeChannelMembers( channel: String, uuids: List, limit: Int?, @@ -1395,7 +1395,7 @@ interface PubNub : * @param cipherKey Key to be used to encrypt uploaded data. If not provided, * cipherKey in @see [PNConfiguration] will be used, if provided. */ - override fun sendFile( + actual fun sendFile( channel: String, fileName: String, inputStream: InputStream, @@ -1413,7 +1413,7 @@ interface PubNub : * @param limit Number of files to return. Minimum value is 1, and maximum is 100. Default value is 100. * @param next Previously-returned cursor bookmark for fetching the next page. @see [PNPage.PNNext] */ - override fun listFiles( + actual fun listFiles( channel: String, limit: Int?, next: PNPage.PNNext?, @@ -1426,7 +1426,7 @@ interface PubNub : * @param fileName Name under which the uploaded file is stored. * @param fileId Unique identifier for the file, assigned during upload. */ - override fun getFileUrl( + actual fun getFileUrl( channel: String, fileName: String, fileId: String, @@ -1441,7 +1441,7 @@ interface PubNub : * @param cipherKey Key to be used to decrypt downloaded data. If a key is not provided, * the SDK uses the cipherKey from the @see [PNConfiguration]. */ - override fun downloadFile( + actual fun downloadFile( channel: String, fileName: String, fileId: String, @@ -1455,7 +1455,7 @@ interface PubNub : * @param fileName Name under which the uploaded file is stored. * @param fileId Unique identifier for the file, assigned during upload. */ - override fun deleteFile( + actual fun deleteFile( channel: String, fileName: String, fileId: String, @@ -1485,7 +1485,7 @@ interface PubNub : * If not specified, then the history configuration of the key is used. * */ - override fun publishFileMessage( + actual fun publishFileMessage( channel: String, fileName: String, fileId: String, @@ -1513,7 +1513,7 @@ interface PubNub : * @param withPresence Also subscribe to related presence channel. * @param withTimetoken A timetoken to start the subscribe loop from. */ - override fun subscribe( + actual fun subscribe( channels: List, channelGroups: List, withPresence: Boolean, @@ -1537,8 +1537,14 @@ interface PubNub : * @param channels Channels to subscribe/unsubscribe. Either `channel` or [channelGroups] are required. * @param channelGroups Channel groups to subscribe/unsubscribe. Either `channelGroups` or [channels] are required. */ - override fun unsubscribe( + actual fun unsubscribe( channels: List, channelGroups: List, ) + + actual override fun subscriptionSetOf( + channels: Set, + channelGroups: Set, + options: SubscriptionOptions + ): SubscriptionSet } diff --git a/pubnub-kotlin/pubnub-kotlin-api/src/jvmMain/kotlin/com/pubnub/kmp/factories.jvm.kt b/pubnub-kotlin/pubnub-kotlin-api/src/jvmMain/kotlin/com/pubnub/kmp/factories.jvm.kt index b0daa24f0..4fba1c07f 100644 --- a/pubnub-kotlin/pubnub-kotlin-api/src/jvmMain/kotlin/com/pubnub/kmp/factories.jvm.kt +++ b/pubnub-kotlin/pubnub-kotlin-api/src/jvmMain/kotlin/com/pubnub/kmp/factories.jvm.kt @@ -11,20 +11,19 @@ import com.pubnub.api.models.consumer.pubsub.objects.PNObjectEventResult import com.pubnub.api.v2.PNConfiguration import com.pubnub.api.v2.callbacks.EventListener import com.pubnub.api.v2.callbacks.StatusListener -import com.pubnub.kmp.PubNub as PubNubKmp -actual fun createPubNub(config: PNConfiguration): PubNubKmp { +actual fun createPubNub(config: PNConfiguration): PubNub { return PubNub.create(config) } actual fun createEventListener( - pubnub: PubNubKmp, - onMessage: (PubNubKmp, PNMessageResult) -> Unit, - onPresence: (PubNubKmp, PNPresenceEventResult) -> Unit, - onSignal: (PubNubKmp, PNSignalResult) -> Unit, - onMessageAction: (PubNubKmp, PNMessageActionResult) -> Unit, - onObjects: (PubNubKmp, PNObjectEventResult) -> Unit, - onFile: (PubNubKmp, PNFileEventResult) -> Unit + pubnub: PubNub, + onMessage: (PubNub, PNMessageResult) -> Unit, + onPresence: (PubNub, PNPresenceEventResult) -> Unit, + onSignal: (PubNub, PNSignalResult) -> Unit, + onMessageAction: (PubNub, PNMessageActionResult) -> Unit, + onObjects: (PubNub, PNObjectEventResult) -> Unit, + onFile: (PubNub, PNFileEventResult) -> Unit ): EventListener { return object : EventListener { override fun message(pubnub: PubNub, result: PNMessageResult) { @@ -54,8 +53,8 @@ actual fun createEventListener( } actual fun createStatusListener( - pubnub: PubNubKmp, - onStatus: (PubNubKmp, PNStatus) -> Unit + pubnub: PubNub, + onStatus: (PubNub, PNStatus) -> Unit ): StatusListener { return object : StatusListener { override fun status(pubnub: PubNub, status: PNStatus) { diff --git a/pubnub-kotlin/pubnub-kotlin-api/src/nonJvm/kotlin/com/pubnub/api/PubNub.nonJvm.kt b/pubnub-kotlin/pubnub-kotlin-api/src/nonJvm/kotlin/com/pubnub/api/PubNub.nonJvm.kt new file mode 100644 index 000000000..12e29a987 --- /dev/null +++ b/pubnub-kotlin/pubnub-kotlin-api/src/nonJvm/kotlin/com/pubnub/api/PubNub.nonJvm.kt @@ -0,0 +1,444 @@ +package com.pubnub.api + +import com.pubnub.api.callbacks.Listener +import com.pubnub.api.endpoints.DeleteMessages +import com.pubnub.api.endpoints.FetchMessages +import com.pubnub.api.endpoints.MessageCounts +import com.pubnub.api.endpoints.Time +import com.pubnub.api.endpoints.access.GrantToken +import com.pubnub.api.endpoints.access.RevokeToken +import com.pubnub.api.endpoints.channel_groups.AddChannelChannelGroup +import com.pubnub.api.endpoints.channel_groups.AllChannelsChannelGroup +import com.pubnub.api.endpoints.channel_groups.DeleteChannelGroup +import com.pubnub.api.endpoints.channel_groups.ListAllChannelGroup +import com.pubnub.api.endpoints.channel_groups.RemoveChannelChannelGroup +import com.pubnub.api.endpoints.files.DeleteFile +import com.pubnub.api.endpoints.files.DownloadFile +import com.pubnub.api.endpoints.files.GetFileUrl +import com.pubnub.api.endpoints.files.ListFiles +import com.pubnub.api.endpoints.files.PublishFileMessage +import com.pubnub.api.endpoints.files.SendFile +import com.pubnub.api.endpoints.message_actions.AddMessageAction +import com.pubnub.api.endpoints.message_actions.GetMessageActions +import com.pubnub.api.endpoints.message_actions.RemoveMessageAction +import com.pubnub.api.endpoints.objects.channel.GetAllChannelMetadata +import com.pubnub.api.endpoints.objects.channel.GetChannelMetadata +import com.pubnub.api.endpoints.objects.channel.RemoveChannelMetadata +import com.pubnub.api.endpoints.objects.channel.SetChannelMetadata +import com.pubnub.api.endpoints.objects.member.GetChannelMembers +import com.pubnub.api.endpoints.objects.member.ManageChannelMembers +import com.pubnub.api.endpoints.objects.membership.GetMemberships +import com.pubnub.api.endpoints.objects.membership.ManageMemberships +import com.pubnub.api.endpoints.objects.uuid.GetAllUUIDMetadata +import com.pubnub.api.endpoints.objects.uuid.GetUUIDMetadata +import com.pubnub.api.endpoints.objects.uuid.RemoveUUIDMetadata +import com.pubnub.api.endpoints.objects.uuid.SetUUIDMetadata +import com.pubnub.api.endpoints.presence.GetState +import com.pubnub.api.endpoints.presence.HereNow +import com.pubnub.api.endpoints.presence.SetState +import com.pubnub.api.endpoints.presence.WhereNow +import com.pubnub.api.endpoints.pubsub.Publish +import com.pubnub.api.endpoints.pubsub.Signal +import com.pubnub.api.endpoints.push.AddChannelsToPush +import com.pubnub.api.endpoints.push.ListPushProvisions +import com.pubnub.api.endpoints.push.RemoveAllPushChannelsForDevice +import com.pubnub.api.endpoints.push.RemoveChannelsFromPush +import com.pubnub.api.enums.PNPushEnvironment +import com.pubnub.api.enums.PNPushType +import com.pubnub.api.models.consumer.PNBoundedPage +import com.pubnub.api.models.consumer.access_manager.v3.ChannelGrant +import com.pubnub.api.models.consumer.access_manager.v3.ChannelGroupGrant +import com.pubnub.api.models.consumer.access_manager.v3.PNToken +import com.pubnub.api.models.consumer.access_manager.v3.UUIDGrant +import com.pubnub.api.models.consumer.message_actions.PNMessageAction +import com.pubnub.api.models.consumer.objects.PNKey +import com.pubnub.api.models.consumer.objects.PNMemberKey +import com.pubnub.api.models.consumer.objects.PNMembershipKey +import com.pubnub.api.models.consumer.objects.PNPage +import com.pubnub.api.models.consumer.objects.PNSortKey +import com.pubnub.api.models.consumer.objects.member.MemberInput +import com.pubnub.api.models.consumer.objects.member.PNUUIDDetailsLevel +import com.pubnub.api.models.consumer.objects.membership.ChannelMembershipInput +import com.pubnub.api.models.consumer.objects.membership.PNChannelDetailsLevel +import com.pubnub.api.v2.PNConfiguration +import com.pubnub.api.v2.callbacks.EventListener +import com.pubnub.api.v2.callbacks.StatusListener +import com.pubnub.api.v2.entities.Channel +import com.pubnub.api.v2.entities.ChannelGroup +import com.pubnub.api.v2.entities.ChannelMetadata +import com.pubnub.api.v2.entities.UserMetadata +import com.pubnub.api.v2.subscriptions.Subscription +import com.pubnub.api.v2.subscriptions.SubscriptionOptions +import com.pubnub.api.v2.subscriptions.SubscriptionSet +import com.pubnub.kmp.CustomObject +import com.pubnub.kmp.Uploadable + +actual interface PubNub { + actual val configuration: PNConfiguration + + actual fun addListener(listener: EventListener) + + actual fun addListener(listener: StatusListener) + + actual fun removeListener(listener: Listener) + + actual fun removeAllListeners() + + actual fun publish( + channel: String, + message: Any, + meta: Any?, + shouldStore: Boolean, + usePost: Boolean, + replicate: Boolean, + ttl: Int? + ): Publish + + actual fun fire( + channel: String, + message: Any, + meta: Any?, + usePost: Boolean, + ttl: Int? + ): Publish + + actual fun signal(channel: String, message: Any): Signal + + actual fun getSubscribedChannels(): List + + actual fun getSubscribedChannelGroups(): List + + actual fun addPushNotificationsOnChannels( + pushType: PNPushType, + channels: List, + deviceId: String, + topic: String?, + environment: PNPushEnvironment + ): AddChannelsToPush + + actual fun auditPushChannelProvisions( + pushType: PNPushType, + deviceId: String, + topic: String?, + environment: PNPushEnvironment + ): ListPushProvisions + + actual fun removePushNotificationsFromChannels( + pushType: PNPushType, + channels: List, + deviceId: String, + topic: String?, + environment: PNPushEnvironment + ): RemoveChannelsFromPush + + actual fun removeAllPushNotificationsFromDeviceWithPushToken( + pushType: PNPushType, + deviceId: String, + topic: String?, + environment: PNPushEnvironment + ): RemoveAllPushChannelsForDevice + + actual fun fetchMessages( + channels: List, + page: PNBoundedPage, + includeUUID: Boolean, + includeMeta: Boolean, + includeMessageActions: Boolean, + includeMessageType: Boolean + ): FetchMessages + + actual fun deleteMessages( + channels: List, + start: Long?, + end: Long? + ): DeleteMessages + + actual fun messageCounts( + channels: List, + channelsTimetoken: List + ): MessageCounts + + actual fun hereNow( + channels: List, + channelGroups: List, + includeState: Boolean, + includeUUIDs: Boolean + ): HereNow + + actual fun whereNow(uuid: String): WhereNow + + actual fun setPresenceState( + channels: List, + channelGroups: List, + state: Any + ): SetState + + actual fun getPresenceState( + channels: List, + channelGroups: List, + uuid: String + ): GetState + + actual fun presence( + channels: List, + channelGroups: List, + connected: Boolean + ) + + actual fun addMessageAction( + channel: String, + messageAction: PNMessageAction + ): AddMessageAction + + actual fun removeMessageAction( + channel: String, + messageTimetoken: Long, + actionTimetoken: Long + ): RemoveMessageAction + + actual fun getMessageActions( + channel: String, + page: PNBoundedPage + ): GetMessageActions + + actual fun addChannelsToChannelGroup( + channels: List, + channelGroup: String + ): AddChannelChannelGroup + + actual fun listChannelsForChannelGroup(channelGroup: String): AllChannelsChannelGroup + + actual fun removeChannelsFromChannelGroup( + channels: List, + channelGroup: String + ): RemoveChannelChannelGroup + + actual fun listAllChannelGroups(): ListAllChannelGroup + + actual fun deleteChannelGroup(channelGroup: String): DeleteChannelGroup + + actual fun grantToken( + ttl: Int, + meta: CustomObject?, + authorizedUUID: String?, + channels: List, + channelGroups: List, + uuids: List + ): GrantToken + + actual fun revokeToken(token: String): RevokeToken + + actual fun time(): Time + + actual fun getAllChannelMetadata( + limit: Int?, + page: PNPage?, + filter: String?, + sort: Collection>, + includeCount: Boolean, + includeCustom: Boolean + ): GetAllChannelMetadata + + actual fun getChannelMetadata( + channel: String, + includeCustom: Boolean + ): GetChannelMetadata + + actual fun setChannelMetadata( + channel: String, + name: String?, + description: String?, + custom: CustomObject?, + includeCustom: Boolean, + type: String?, + status: String? + ): SetChannelMetadata + + actual fun removeChannelMetadata(channel: String): RemoveChannelMetadata + + actual fun getAllUUIDMetadata( + limit: Int?, + page: PNPage?, + filter: String?, + sort: Collection>, + includeCount: Boolean, + includeCustom: Boolean + ): GetAllUUIDMetadata + + actual fun getUUIDMetadata( + uuid: String?, + includeCustom: Boolean + ): GetUUIDMetadata + + actual fun setUUIDMetadata( + uuid: String?, + name: String?, + externalId: String?, + profileUrl: String?, + email: String?, + custom: CustomObject?, + includeCustom: Boolean, + type: String?, + status: String? + ): SetUUIDMetadata + + actual fun removeUUIDMetadata(uuid: String?): RemoveUUIDMetadata + + actual fun getMemberships( + uuid: String?, + limit: Int?, + page: PNPage?, + filter: String?, + sort: Collection>, + includeCount: Boolean, + includeCustom: Boolean, + includeChannelDetails: PNChannelDetailsLevel?, + includeType: Boolean + ): GetMemberships + + actual fun setMemberships( + channels: List, + uuid: String?, + limit: Int?, + page: PNPage?, + filter: String?, + sort: Collection>, + includeCount: Boolean, + includeCustom: Boolean, + includeChannelDetails: PNChannelDetailsLevel?, + includeType: Boolean + ): ManageMemberships + + actual fun removeMemberships( + channels: List, + uuid: String?, + limit: Int?, + page: PNPage?, + filter: String?, + sort: Collection>, + includeCount: Boolean, + includeCustom: Boolean, + includeChannelDetails: PNChannelDetailsLevel?, + includeType: Boolean + ): ManageMemberships + + actual fun getChannelMembers( + channel: String, + limit: Int?, + page: PNPage?, + filter: String?, + sort: Collection>, + includeCount: Boolean, + includeCustom: Boolean, + includeUUIDDetails: PNUUIDDetailsLevel?, + includeType: Boolean + ): GetChannelMembers + + actual fun setChannelMembers( + channel: String, + uuids: List, + limit: Int?, + page: PNPage?, + filter: String?, + sort: Collection>, + includeCount: Boolean, + includeCustom: Boolean, + includeUUIDDetails: PNUUIDDetailsLevel?, + includeType: Boolean + ): ManageChannelMembers + + actual fun removeChannelMembers( + channel: String, + uuids: List, + limit: Int?, + page: PNPage?, + filter: String?, + sort: Collection>, + includeCount: Boolean, + includeCustom: Boolean, + includeUUIDDetails: PNUUIDDetailsLevel?, + includeType: Boolean + ): ManageChannelMembers + + actual fun listFiles( + channel: String, + limit: Int?, + next: PNPage.PNNext? + ): ListFiles + + actual fun getFileUrl( + channel: String, + fileName: String, + fileId: String + ): GetFileUrl + + actual fun sendFile( + channel: String, + fileName: String, + inputStream: Uploadable, + message: Any?, + meta: Any?, + ttl: Int?, + shouldStore: Boolean?, + cipherKey: String? + ): SendFile + + actual fun downloadFile( + channel: String, + fileName: String, + fileId: String, + cipherKey: String? + ): DownloadFile + + actual fun deleteFile( + channel: String, + fileName: String, + fileId: String + ): DeleteFile + + actual fun publishFileMessage( + channel: String, + fileName: String, + fileId: String, + message: Any?, + meta: Any?, + ttl: Int?, + shouldStore: Boolean? + ): PublishFileMessage + + actual fun subscribe( + channels: List, + channelGroups: List, + withPresence: Boolean, + withTimetoken: Long + ) + + actual fun unsubscribe( + channels: List, + channelGroups: List + ) + + actual fun unsubscribeAll() + + actual fun setToken(token: String?) + + actual fun destroy() + + actual fun channel(name: String): Channel + + actual fun channelGroup(name: String): ChannelGroup + + actual fun channelMetadata(id: String): ChannelMetadata + + actual fun userMetadata(id: String): UserMetadata + + actual fun subscriptionSetOf(subscriptions: Set): SubscriptionSet + + actual fun subscriptionSetOf( + channels: Set, + channelGroups: Set, + options: SubscriptionOptions + ): SubscriptionSet + + actual fun parseToken(token: String): PNToken +} diff --git a/pubnub-kotlin/pubnub-kotlin-impl/src/main/kotlin/com/pubnub/internal/v2/PNConfigurationImpl.kt b/pubnub-kotlin/pubnub-kotlin-impl/src/main/kotlin/com/pubnub/internal/v2/PNConfigurationImpl.kt index e141c822d..8dab21e95 100644 --- a/pubnub-kotlin/pubnub-kotlin-impl/src/main/kotlin/com/pubnub/internal/v2/PNConfigurationImpl.kt +++ b/pubnub-kotlin/pubnub-kotlin-impl/src/main/kotlin/com/pubnub/internal/v2/PNConfigurationImpl.kt @@ -63,142 +63,142 @@ class PNConfigurationImpl( BasePNConfigurationImpl.Builder(defaultConfiguration), PNConfiguration.Builder, PNConfigurationOverride.Builder { - private val log = LoggerFactory.getLogger(this::class.simpleName) + private val log = LoggerFactory.getLogger(this::class.simpleName) - override var userId: UserId = super.userId + override var userId: UserId = super.userId - override var subscribeKey: String = super.subscribeKey + override var subscribeKey: String = super.subscribeKey - override var publishKey: String = super.publishKey + override var publishKey: String = super.publishKey - override var secretKey: String = super.secretKey + override var secretKey: String = super.secretKey - override var authKey: String = super.authKey + override var authKey: String = super.authKey - override var cryptoModule: CryptoModule? = super.cryptoModule + override var cryptoModule: CryptoModule? = super.cryptoModule - override var origin: String = super.origin + override var origin: String = super.origin - override var secure: Boolean = super.secure + override var secure: Boolean = super.secure - override var logVerbosity: PNLogVerbosity = super.logVerbosity + override var logVerbosity: PNLogVerbosity = super.logVerbosity - override var heartbeatNotificationOptions: PNHeartbeatNotificationOptions = super.heartbeatNotificationOptions + override var heartbeatNotificationOptions: PNHeartbeatNotificationOptions = super.heartbeatNotificationOptions - override var presenceTimeout: Int = super.presenceTimeout - set(value) { - field = - if (value < MINIMUM_PRESENCE_TIMEOUT) { - log.warn("Presence timeout is too low. Defaulting to: $MINIMUM_PRESENCE_TIMEOUT") - MINIMUM_PRESENCE_TIMEOUT - } else { - value - } - heartbeatInterval = (presenceTimeout / 2) - 1 - } + override var presenceTimeout: Int = super.presenceTimeout + set(value) { + field = + if (value < MINIMUM_PRESENCE_TIMEOUT) { + log.warn("Presence timeout is too low. Defaulting to: $MINIMUM_PRESENCE_TIMEOUT") + MINIMUM_PRESENCE_TIMEOUT + } else { + value + } + heartbeatInterval = (presenceTimeout / 2) - 1 + } - override var heartbeatInterval: Int = super.heartbeatInterval + override var heartbeatInterval: Int = super.heartbeatInterval - override var subscribeTimeout: Int = super.subscribeTimeout + override var subscribeTimeout: Int = super.subscribeTimeout - override var connectTimeout: Int = super.connectTimeout + override var connectTimeout: Int = super.connectTimeout - @Deprecated( - "This setting relates to *read* timeout and was renamed to `nonSubscribeReadTimeout`", - replaceWith = ReplaceWith("nonSubscribeReadTimeout") - ) - override var nonSubscribeRequestTimeout: Int - get() = nonSubscribeReadTimeout - set(value) { - nonSubscribeReadTimeout = value - } - - override var nonSubscribeReadTimeout: Int = super.nonSubscribeReadTimeout - - override var cacheBusting: Boolean = super.cacheBusting - - override var suppressLeaveEvents: Boolean = super.suppressLeaveEvents - - override var maintainPresenceState: Boolean = super.maintainPresenceState - - override var filterExpression: String = super.filterExpression - - override var includeInstanceIdentifier: Boolean = super.includeInstanceIdentifier - - override var includeRequestIdentifier: Boolean = super.includeRequestIdentifier - - override var maximumConnections: Int? = super.maximumConnections - - override var googleAppEngineNetworking: Boolean = super.googleAppEngineNetworking - - override var proxy: Proxy? = super.proxy - - override var proxySelector: ProxySelector? = super.proxySelector - - override var proxyAuthenticator: Authenticator? = super.proxyAuthenticator - - override var certificatePinner: CertificatePinner? = super.certificatePinner - - override var httpLoggingInterceptor: HttpLoggingInterceptor? = super.httpLoggingInterceptor - - override var sslSocketFactory: SSLSocketFactory? = super.sslSocketFactory - - override var x509ExtendedTrustManager: X509ExtendedTrustManager? = super.x509ExtendedTrustManager - - override var connectionSpec: ConnectionSpec? = super.connectionSpec - - override var hostnameVerifier: HostnameVerifier? = super.hostnameVerifier - - override var fileMessagePublishRetryLimit: Int = super.fileMessagePublishRetryLimit - override var dedupOnSubscribe: Boolean = super.dedupOnSubscribe - override var maximumMessagesCacheSize: Int = super.maximumMessagesCacheSize - override var pnsdkSuffixes: Map = super.pnsdkSuffixes - - override var retryConfiguration: RetryConfiguration = super.retryConfiguration - - override var managePresenceListManually: Boolean = super.managePresenceListManually - - override fun build(): PNConfiguration { - return PNConfigurationImpl( - userId = userId, - subscribeKey = subscribeKey, - publishKey = publishKey, - secretKey = secretKey, - authKey = authKey, - cryptoModule = cryptoModule, - origin = origin, - secure = secure, - logVerbosity = logVerbosity, - heartbeatNotificationOptions = heartbeatNotificationOptions, - presenceTimeout = presenceTimeout, - heartbeatInterval = heartbeatInterval, - subscribeTimeout = subscribeTimeout, - connectTimeout = connectTimeout, - nonSubscribeReadTimeout = nonSubscribeReadTimeout, - cacheBusting = cacheBusting, - suppressLeaveEvents = suppressLeaveEvents, - maintainPresenceState = maintainPresenceState, - filterExpression = filterExpression, - includeInstanceIdentifier = includeInstanceIdentifier, - includeRequestIdentifier = includeRequestIdentifier, - maximumConnections = maximumConnections, - googleAppEngineNetworking = googleAppEngineNetworking, - proxy = proxy, - proxySelector = proxySelector, - proxyAuthenticator = proxyAuthenticator, - certificatePinner = certificatePinner, - httpLoggingInterceptor = httpLoggingInterceptor, - sslSocketFactory = sslSocketFactory, - x509ExtendedTrustManager = x509ExtendedTrustManager, - connectionSpec = connectionSpec, - hostnameVerifier = hostnameVerifier, - fileMessagePublishRetryLimit = fileMessagePublishRetryLimit, - dedupOnSubscribe = dedupOnSubscribe, - maximumMessagesCacheSize = maximumMessagesCacheSize, - pnsdkSuffixes = pnsdkSuffixes, - retryConfiguration = retryConfiguration, - managePresenceListManually = managePresenceListManually, - ) + @Deprecated( + "This setting relates to *read* timeout and was renamed to `nonSubscribeReadTimeout`", + replaceWith = ReplaceWith("nonSubscribeReadTimeout") + ) + override var nonSubscribeRequestTimeout: Int + get() = nonSubscribeReadTimeout + set(value) { + nonSubscribeReadTimeout = value } + + override var nonSubscribeReadTimeout: Int = super.nonSubscribeReadTimeout + + override var cacheBusting: Boolean = super.cacheBusting + + override var suppressLeaveEvents: Boolean = super.suppressLeaveEvents + + override var maintainPresenceState: Boolean = super.maintainPresenceState + + override var filterExpression: String = super.filterExpression + + override var includeInstanceIdentifier: Boolean = super.includeInstanceIdentifier + + override var includeRequestIdentifier: Boolean = super.includeRequestIdentifier + + override var maximumConnections: Int? = super.maximumConnections + + override var googleAppEngineNetworking: Boolean = super.googleAppEngineNetworking + + override var proxy: Proxy? = super.proxy + + override var proxySelector: ProxySelector? = super.proxySelector + + override var proxyAuthenticator: Authenticator? = super.proxyAuthenticator + + override var certificatePinner: CertificatePinner? = super.certificatePinner + + override var httpLoggingInterceptor: HttpLoggingInterceptor? = super.httpLoggingInterceptor + + override var sslSocketFactory: SSLSocketFactory? = super.sslSocketFactory + + override var x509ExtendedTrustManager: X509ExtendedTrustManager? = super.x509ExtendedTrustManager + + override var connectionSpec: ConnectionSpec? = super.connectionSpec + + override var hostnameVerifier: HostnameVerifier? = super.hostnameVerifier + + override var fileMessagePublishRetryLimit: Int = super.fileMessagePublishRetryLimit + override var dedupOnSubscribe: Boolean = super.dedupOnSubscribe + override var maximumMessagesCacheSize: Int = super.maximumMessagesCacheSize + override var pnsdkSuffixes: Map = super.pnsdkSuffixes + + override var retryConfiguration: RetryConfiguration = super.retryConfiguration + + override var managePresenceListManually: Boolean = super.managePresenceListManually + + override fun build(): PNConfiguration { + return PNConfigurationImpl( + userId = userId, + subscribeKey = subscribeKey, + publishKey = publishKey, + secretKey = secretKey, + authKey = authKey, + cryptoModule = cryptoModule, + origin = origin, + secure = secure, + logVerbosity = logVerbosity, + heartbeatNotificationOptions = heartbeatNotificationOptions, + presenceTimeout = presenceTimeout, + heartbeatInterval = heartbeatInterval, + subscribeTimeout = subscribeTimeout, + connectTimeout = connectTimeout, + nonSubscribeReadTimeout = nonSubscribeReadTimeout, + cacheBusting = cacheBusting, + suppressLeaveEvents = suppressLeaveEvents, + maintainPresenceState = maintainPresenceState, + filterExpression = filterExpression, + includeInstanceIdentifier = includeInstanceIdentifier, + includeRequestIdentifier = includeRequestIdentifier, + maximumConnections = maximumConnections, + googleAppEngineNetworking = googleAppEngineNetworking, + proxy = proxy, + proxySelector = proxySelector, + proxyAuthenticator = proxyAuthenticator, + certificatePinner = certificatePinner, + httpLoggingInterceptor = httpLoggingInterceptor, + sslSocketFactory = sslSocketFactory, + x509ExtendedTrustManager = x509ExtendedTrustManager, + connectionSpec = connectionSpec, + hostnameVerifier = hostnameVerifier, + fileMessagePublishRetryLimit = fileMessagePublishRetryLimit, + dedupOnSubscribe = dedupOnSubscribe, + maximumMessagesCacheSize = maximumMessagesCacheSize, + pnsdkSuffixes = pnsdkSuffixes, + retryConfiguration = retryConfiguration, + managePresenceListManually = managePresenceListManually, + ) } + } } diff --git a/pubnub-kotlin/pubnub-kotlin-test/src/commonMain/kotlin/com.pubnub.test/BaseIntegrationTest.kt b/pubnub-kotlin/pubnub-kotlin-test/src/commonMain/kotlin/com.pubnub.test/BaseIntegrationTest.kt index da4cdf3e6..10b159fa2 100644 --- a/pubnub-kotlin/pubnub-kotlin-test/src/commonMain/kotlin/com.pubnub.test/BaseIntegrationTest.kt +++ b/pubnub-kotlin/pubnub-kotlin-test/src/commonMain/kotlin/com.pubnub.test/BaseIntegrationTest.kt @@ -1,5 +1,6 @@ package com.pubnub.test +import com.pubnub.api.PubNub import com.pubnub.api.UserId import com.pubnub.api.enums.PNLogVerbosity import com.pubnub.api.enums.PNStatusCategory @@ -11,7 +12,6 @@ import com.pubnub.api.v2.createPNConfiguration import com.pubnub.api.v2.subscriptions.EmptyOptions import com.pubnub.api.v2.subscriptions.SubscriptionOptions import com.pubnub.kmp.PNFuture -import com.pubnub.kmp.PubNub import com.pubnub.kmp.createEventListener import com.pubnub.kmp.createPubNub import com.pubnub.kmp.createStatusListener diff --git a/pubnub-kotlin/pubnub-kotlin-test/src/commonMain/kotlin/com.pubnub.test/FakePubNub.kt b/pubnub-kotlin/pubnub-kotlin-test/src/commonMain/kotlin/com.pubnub.test/FakePubNub.kt index 94b0b93bd..035902256 100644 --- a/pubnub-kotlin/pubnub-kotlin-test/src/commonMain/kotlin/com.pubnub.test/FakePubNub.kt +++ b/pubnub-kotlin/pubnub-kotlin-test/src/commonMain/kotlin/com.pubnub.test/FakePubNub.kt @@ -1,5 +1,6 @@ package com.pubnub.test +import com.pubnub.api.PubNub import com.pubnub.api.callbacks.Listener import com.pubnub.api.endpoints.DeleteMessages import com.pubnub.api.endpoints.FetchMessages @@ -70,7 +71,6 @@ import com.pubnub.api.v2.subscriptions.Subscription import com.pubnub.api.v2.subscriptions.SubscriptionOptions import com.pubnub.api.v2.subscriptions.SubscriptionSet import com.pubnub.kmp.CustomObject -import com.pubnub.kmp.PubNub import com.pubnub.kmp.Uploadable private fun notImplemented(): Nothing = TODO("Not implemented")