chore: Update readme

This commit is contained in:
Christian Pauly 2021-06-18 10:10:24 +02:00
parent c0c7f68bf3
commit 45a2472fcd
1 changed files with 22 additions and 9 deletions

View File

@ -15,7 +15,10 @@ For flutter apps you can easily import it with the [flutter_olm](https://pub.dev
1. Import the sdk 1. Import the sdk
```yaml ```yaml
matrix: matrix: <latest-version>
# Optional:
flutter_olm: <latest-version>
flutter_openssl_crypto: <latest-version>
``` ```
```dart ```dart
@ -28,7 +31,19 @@ import 'package:matrix/matrix.dart';
final client = Client("HappyChat"); final client = Client("HappyChat");
``` ```
The SDK works better with a Moor database. Otherwise it has no persistence. [Take a look here for an example store](https://gitlab.com/famedly/fluffychat/-/tree/main/lib/utils/database). The SDK works better with a database. Otherwise it has no persistence. For this you need to provide a databaseBuilder like this:
```dart
final client = Client(
"HappyChat",
databaseBuilder: (Client client) async {
await Hive.init('/path/to/your/storage');
final db = FamedlySdkHiveDatabase(client.clientName);
await db.open();
return db;
},
);
```
3. Connect to a Matrix Homeserver and listen to the streams: 3. Connect to a Matrix Homeserver and listen to the streams:
@ -45,13 +60,11 @@ client.onRoomUpdate.stream.listen((RoomUpdate eventUpdate){
print("New room update!"); print("New room update!");
}); });
try { await client.checkHomeserver("https://yourhomeserver.abc");
await client.checkHomeserver("https://yourhomeserver.abc"); await client.login(
await client.login("username", "password"); identifier: AuthenticationUserIdentifier(user: 'alice'),
} password: '123456',
catch(e) { );
print('No luck...');
}
``` ```
4. Send a message to a Room: 4. Send a message to a Room: