Skip to content

Commit

Permalink
Use client config
Browse files Browse the repository at this point in the history
  • Loading branch information
clementetb committed Jun 10, 2024
1 parent c8e3780 commit 6e6f4ea
Show file tree
Hide file tree
Showing 5 changed files with 9 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -519,7 +519,6 @@ expect object RealmInterop {
// App
fun realm_app_get(
appConfig: RealmAppConfigurationPointer,
syncClientConfig: RealmSyncClientConfigurationPointer,
basePath: String,
): RealmAppPointer
fun realm_app_get_current_user(app: RealmAppPointer): RealmUserPointer?
Expand Down Expand Up @@ -599,8 +598,7 @@ expect object RealmInterop {
fun realm_user_refresh_custom_data(app: RealmAppPointer, user: RealmUserPointer, callback: AppCallback<Unit>)

// Sync client config
fun realm_sync_client_config_new(): RealmSyncClientConfigurationPointer

fun realm_app_config_get_sync_client_config(configPointer: RealmAppConfigurationPointer): RealmSyncClientConfigurationPointer
fun realm_sync_client_config_set_default_binding_thread_observer(
syncClientConfig: RealmSyncClientConfigurationPointer,
appId: String
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1154,7 +1154,6 @@ actual object RealmInterop {

actual fun realm_app_get(
appConfig: RealmAppConfigurationPointer,
syncClientConfig: RealmSyncClientConfigurationPointer,
basePath: String
): RealmAppPointer {
return LongPointerWrapper(realmc.realm_app_create(appConfig.cptr()), managed = true)
Expand Down Expand Up @@ -1310,8 +1309,8 @@ actual object RealmInterop {
)
}

actual fun realm_sync_client_config_new(): RealmSyncClientConfigurationPointer {
return LongPointerWrapper(realmc.realm_sync_client_config_new())
actual fun realm_app_config_get_sync_client_config(configPointer: RealmAppConfigurationPointer): RealmSyncClientConfigurationPointer {
return LongPointerWrapper(realmc.realm_app_config_get_sync_client_config(configPointer.cptr()))
}

actual fun realm_sync_client_config_set_default_binding_thread_observer(syncClientConfig: RealmSyncClientConfigurationPointer, appId: String) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2063,7 +2063,6 @@ actual object RealmInterop {

actual fun realm_app_get(
appConfig: RealmAppConfigurationPointer,
syncClientConfig: RealmSyncClientConfigurationPointer,
basePath: String
): RealmAppPointer {
return CPointerWrapper(realm_wrapper.realm_app_create(appConfig.cptr()), managed = true)
Expand Down Expand Up @@ -2466,8 +2465,8 @@ actual object RealmInterop {
)
}

actual fun realm_sync_client_config_new(): RealmSyncClientConfigurationPointer {
return CPointerWrapper(realm_wrapper.realm_sync_client_config_new())
actual fun realm_app_config_get_sync_client_config(configPointer: RealmAppConfigurationPointer): RealmSyncClientConfigurationPointer {
return CPointerWrapper(realm_wrapper.realm_app_config_get_sync_client_config(configPointer.cptr()))
}

actual fun realm_sync_client_config_set_default_binding_thread_observer(
Expand Down
2 changes: 0 additions & 2 deletions packages/jni-swig-stub/realm.i
Original file line number Diff line number Diff line change
Expand Up @@ -525,8 +525,6 @@ $result = SWIG_JavaArrayOutLonglong(jenv, (long long *)result, 2);
%ignore "realm_dictionary_add_notification_callback";
%ignore "realm_results_add_notification_callback";

%ignore "realm_app_config_get_sync_client_config";

// Swig doesn't understand __attribute__ so eliminate it
#define __attribute__(x)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,9 @@ public class AppConfigurationImpl @OptIn(ExperimentalKBsonSerializerApi::class)
applicationInfo = info.toString()
}
val sdkInfo = "RealmKotlin/$SDK_VERSION"

val synClientConfig: RealmSyncClientConfigurationPointer = initializeSyncClientConfig(
appConfigPointer,
websocketTransport,
sdkInfo,
applicationInfo.toString()
Expand Down Expand Up @@ -158,11 +160,12 @@ public class AppConfigurationImpl @OptIn(ExperimentalKBsonSerializerApi::class)
}

private fun initializeSyncClientConfig(
appConfigPointer: RealmAppConfigurationPointer,
webSocketTransport: WebSocketTransport?,
sdkInfo: String?,
applicationInfo: String?
): RealmSyncClientConfigurationPointer =
RealmInterop.realm_sync_client_config_new()
RealmInterop.realm_app_config_get_sync_client_config(appConfigPointer)
.also { syncClientConfig ->
// Initialize client configuration first
RealmInterop.realm_sync_client_config_set_default_binding_thread_observer(syncClientConfig, appId)
Expand Down

0 comments on commit 6e6f4ea

Please sign in to comment.