famedlysdk/README.md

64 lines
1.4 KiB
Markdown
Raw Permalink Normal View History

2020-06-13 19:40:39 +00:00
+++ This is a fork of famedlysdk to statisfy FurryChat (fork of FluffyChat) needs +++
2019-06-10 10:25:19 +00:00
2019-06-09 10:16:48 +00:00
# famedlysdk
2019-06-09 10:20:59 +00:00
Matrix SDK for the famedly talk app written in dart.
2019-06-09 10:16:48 +00:00
2019-06-10 10:25:19 +00:00
## API
2020-01-04 10:21:54 +00:00
The API is documented here: [famedly.gitlab.io/famedlysdk/famedlysdk/famedlysdk-library.html](https://famedly.gitlab.io/famedlysdk/famedlysdk/famedlysdk-library.html)
2019-06-10 10:25:19 +00:00
2019-06-09 10:20:59 +00:00
## How to use this
2019-06-09 10:16:48 +00:00
2019-06-09 10:20:59 +00:00
1. Import the sdk
2019-06-09 10:16:48 +00:00
2019-06-09 10:20:59 +00:00
```yaml
2019-06-09 12:33:25 +00:00
famedlysdk:
2019-06-09 10:20:59 +00:00
git:
url: https://gitlab.com/famedly/famedlysdk.git
2019-10-02 11:33:01 +00:00
```
2019-06-09 10:20:59 +00:00
```dart
import 'package:flutter/material.dart';
import 'package:famedlysdk/famedlysdk.dart';
2019-10-02 11:33:01 +00:00
```
2. Create a new client:
2019-06-09 10:20:59 +00:00
2019-10-02 11:33:01 +00:00
```dart
2020-10-23 09:34:08 +00:00
Client client = Client("HappyChat");
2019-06-09 10:20:59 +00:00
```
2019-10-16 07:47:41 +00:00
Take a look here for an example store:
2020-01-04 10:21:54 +00:00
[https://gitlab.com/ChristianPauly/fluffychat-flutter/snippets](https://gitlab.com/ChristianPauly/fluffychat-flutter/snippets)
2019-06-09 10:20:59 +00:00
3. Connect to a Matrix Homeserver and listen to the streams:
```dart
2020-10-23 09:34:08 +00:00
client.onLoginStateChanged.stream.listen((bool loginState){
2019-06-09 10:20:59 +00:00
print("LoginState: ${loginState.toString()}");
});
2020-10-23 09:34:08 +00:00
client.onEvent.stream.listen((EventUpdate eventUpdate){
2019-06-09 10:20:59 +00:00
print("New event update!");
});
2020-10-23 09:34:08 +00:00
client.onRoomUpdate.stream.listen((RoomUpdate eventUpdate){
2019-06-09 10:20:59 +00:00
print("New room update!");
});
2020-10-23 09:34:08 +00:00
try {
await client.checkHomeserver("https://yourhomeserver.abc");
await client.login("username", "password");
}
catch(e) {
print('No luck...');
}
2019-06-09 10:20:59 +00:00
```
4. Send a message to a Room:
```dart
2020-10-23 09:34:08 +00:00
await client.getRoomById('your_room_id').sendTextEvent('Hello world');
```