-
-
Notifications
You must be signed in to change notification settings - Fork 29
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
7f55bd3
commit 9c216bb
Showing
41 changed files
with
316 additions
and
386 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,20 +1,60 @@ | ||
# Chat app example | ||
|
||
By default it will run with the Centrifugo public demo instance. To run locally use this configuration for your server: | ||
Before running this example make sure you created `chat` namespace in Centrifugo configuration and allowed publishing into channel - i.e. using config like this: | ||
|
||
```json | ||
{ | ||
... | ||
"token_hmac_secret_key": "9c4a1a64-7479-4c2c-9895-14b0676c71d8", | ||
"admin_password": "a15cfff3-b7b7-4261-87ad-c6825c0400b5", | ||
"admin_secret": "3aaead2e-2d3d-48cb-b330-c54c44b4eac0", | ||
"api_key": "cb0f41cd-5954-443d-8628-a4453592443c", | ||
"allowed_origins": ["http://localhost:8000"], | ||
"namespaces": [ | ||
{ | ||
"name": "chat", | ||
"anonymous": false, | ||
"publish": true, | ||
"join_leave": true, | ||
"presence": true | ||
"presence": true, | ||
"presence_stats": true, | ||
"allow_publish_for_subscriber": true, | ||
"allow_subscribe_for_client": true | ||
} | ||
] | ||
} | ||
``` | ||
|
||
Then change the server address in `conf.dart` | ||
Call `centrifugo genconfig` to create a basic `config.json` at the first time. | ||
|
||
When you use your own configuration, please re-generate the tokens registered in `lib/conf.dart`: | ||
* Use `centrifugo gentoken --user dart` to generate the user's JWT token. | ||
* Use `centrifugo gensubtoken --user dart --channel chat:index` to generate the user's subscription JWT token. | ||
|
||
|
||
Run Centrifugo with the admin option, to later send messages to all subscribers: | ||
|
||
```bash | ||
centrifugo --admin | ||
``` | ||
|
||
|
||
For testing purposes only, you can also run Centrifugo in insecure client mode, so that the validity of JWT tokens | ||
are not checked: | ||
|
||
```bash | ||
centrifugo --client_insecure --admin | ||
``` | ||
|
||
Now check the IP address if your system with `ipconfig` on Windows and `ip adds` on Unix-like systems and change the `serverAddr` variable in `lib/conf.dart` accordingly. | ||
|
||
When the configuration is correct, you can launch the app on the platform of your choice. When running on web, ensure that you specify a port using the `--web-port` argument | ||
and that you have whitelisted that port in your Centrifugo `config.json` file. E.g. `"allowed_origins": ["http://localhost:8000", "http://localhost:3000"]` when running | ||
locally on port 3000: `flutter run -d chrome --web-port 3000`. | ||
|
||
When you have started centrifugo with the `--admin` option, you can also open `http://localhost:8000/#/actions` to send a message to your console app with the | ||
following settings: | ||
* Method: Publish | ||
* Channel: `chat:index` | ||
* Data: `{"message": "hello world", "username": "admin"}` | ||
|
||
Congratulations, you have a running centrifugo system and a Flutter app that connects to it! |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
7 changes: 0 additions & 7 deletions
7
example/chat_app/android-old/app/src/debug/AndroidManifest.xml
This file was deleted.
Oops, something went wrong.
47 changes: 0 additions & 47 deletions
47
example/chat_app/android-old/app/src/main/AndroidManifest.xml
This file was deleted.
Oops, something went wrong.
6 changes: 0 additions & 6 deletions
6
example/chat_app/android-old/app/src/main/kotlin/com/example/chat_app/MainActivity.kt
This file was deleted.
Oops, something went wrong.
12 changes: 0 additions & 12 deletions
12
example/chat_app/android-old/app/src/main/res/drawable-v21/launch_background.xml
This file was deleted.
Oops, something went wrong.
12 changes: 0 additions & 12 deletions
12
example/chat_app/android-old/app/src/main/res/drawable/launch_background.xml
This file was deleted.
Oops, something went wrong.
Binary file removed
BIN
-544 Bytes
example/chat_app/android-old/app/src/main/res/mipmap-hdpi/ic_launcher.png
Binary file not shown.
Binary file removed
BIN
-442 Bytes
example/chat_app/android-old/app/src/main/res/mipmap-mdpi/ic_launcher.png
Binary file not shown.
Binary file removed
BIN
-721 Bytes
example/chat_app/android-old/app/src/main/res/mipmap-xhdpi/ic_launcher.png
Binary file not shown.
Binary file removed
BIN
-1.01 KB
example/chat_app/android-old/app/src/main/res/mipmap-xxhdpi/ic_launcher.png
Binary file not shown.
Binary file removed
BIN
-1.41 KB
example/chat_app/android-old/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png
Binary file not shown.
18 changes: 0 additions & 18 deletions
18
example/chat_app/android-old/app/src/main/res/values-night/styles.xml
This file was deleted.
Oops, something went wrong.
18 changes: 0 additions & 18 deletions
18
example/chat_app/android-old/app/src/main/res/values/styles.xml
This file was deleted.
Oops, something went wrong.
7 changes: 0 additions & 7 deletions
7
example/chat_app/android-old/app/src/profile/AndroidManifest.xml
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
6 changes: 0 additions & 6 deletions
6
example/chat_app/android-old/gradle/wrapper/gradle-wrapper.properties
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.