Skip to content

Commit 4211076

Browse files
SyncClient: add protocolVersion and protocolVersionServer #159
1 parent 419ce2c commit 4211076

File tree

2 files changed

+11
-0
lines changed

2 files changed

+11
-0
lines changed

objectbox/lib/src/native/sync.dart

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -238,6 +238,13 @@ class SyncClient {
238238
/// Returns if this sync client is closed and can no longer be used.
239239
bool isClosed() => _cSync.address == 0;
240240

241+
/// Returns the protocol version this client uses.
242+
static int protocolVersion() => C.sync_protocol_version();
243+
244+
/// Returns the protocol version of the server after a connection is
245+
/// established (or attempted), zero otherwise.
246+
int protocolVersionServer() => C.sync_protocol_version_server(_ptr);
247+
241248
/// Gets the current sync client state.
242249
SyncState state() {
243250
final state = C.sync_state(_ptr);

objectbox_test/test/sync_test.dart

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,7 @@ void main() {
9999

100100
if (Sync.isAvailable()) {
101101
// TESTS to run when SYNC is available
102+
print("Testing Sync with protocol version ${SyncClient.protocolVersion()}");
102103

103104
test('SyncClient lifecycle', () {
104105
expect(store.syncClient(), isNull);
@@ -210,6 +211,9 @@ void main() {
210211
SyncClient c = createClient(store);
211212
expect(c.isClosed(), isFalse);
212213

214+
expect(SyncClient.protocolVersion(), greaterThanOrEqualTo(7));
215+
expect(c.protocolVersionServer(), 0);
216+
213217
c.setCredentials(SyncCredentials.none());
214218
c.setCredentials(SyncCredentials.googleAuthString('secret'));
215219
c.setCredentials(SyncCredentials.sharedSecretString('secret'));

0 commit comments

Comments
 (0)