Mentions légales du service

Skip to content
Snippets Groups Projects
Commit 578ded06 authored by Yannick Li's avatar Yannick Li
Browse files

Adapt to the new CServiceAdapter

parent 32a23c48
No related branches found
No related tags found
2 merge requests!6Resolve "Update to c-crdtlib v1.0.0",!2Draft: Resolve "Clean CService code"
......@@ -73,19 +73,25 @@ open class CObject<T> {
if (this.isClosed) throw RuntimeException("This object has been closed.")
if (this.readOnly) throw RuntimeException("This object has been opened in read-only mode.")
this.crdt = CServiceAdapter.getObject<T>(this.id)
coroutineBlocking {
this.crdt = CServiceAdapter.getObject("myapp", this.id)
}
return (ActiveSession as Session).environment.tick()
}
protected fun afterUpdate() {
CServiceAdapter.updateObject<T>(this.id, this.crdt)
coroutineBlocking {
CServiceAdapter.updateObject("myapp", this.id, this.crdt)
}
}
protected fun beforeGetter() {
if (ActiveTransaction == null) throw RuntimeException("Object function should be call within a transaction.")
if (this.isClosed) throw RuntimeException("This object has been closed.")
this.crdt = CServiceAdapter.getObject<T>(this.id)
coroutineBlocking {
this.crdt = CServiceAdapter.getObject("myapp", this.id)
}
}
protected fun afterGetter() {
......
......@@ -125,7 +125,9 @@ class Session {
}
ActiveSession = null
CServiceAdapter.close(this.clientUId)
coroutineBlocking {
CServiceAdapter.close("myapp")
}
this.isClosed = true
}
......@@ -141,7 +143,9 @@ class Session {
if (ActiveSession != null) throw RuntimeException("Another session is already active.")
val clientUId = ClientUId("MY_ID")
if (!CServiceAdapter.connect(dbName, clientUId)) throw RuntimeException("Connection to server failed.")
coroutineBlocking {
if (!CServiceAdapter.connect(dbName)) throw RuntimeException("Connection to server failed.")
}
val session = Session(clientUId)
ActiveSession = session
return session
......
package client.utils
expect fun coroutineBlocking(block: suspend () -> Unit)
\ No newline at end of file
package client.utils
import kotlinx.coroutines.runBlocking
actual fun coroutineBlocking(block: suspend () -> Unit) = runBlocking { block() }
package client.utils
import kotlinx.coroutines.GlobalScope
import kotlinx.coroutines.await
import kotlinx.coroutines.promise
actual fun coroutineBlocking(block: suspend () -> Unit): dynamic = GlobalScope.promise { block() }
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment