### Update Protobuf Definitions Source: https://github.com/centrifugal/centrifuge-dart/blob/master/README.md Instructions for updating protobuf definitions, including installing protoc and protoc_plugin, and running the protoc command. ```bash protoc --dart_out=. -I . client.proto ``` ```bash dartfmt -w lib/ test/ ``` -------------------------------- ### Run Tests Locally Source: https://github.com/centrifugal/centrifuge-dart/blob/master/README.md Commands to start the test Centrifugo server using Docker and run local tests with Dart. ```bash docker compose up ``` ```bash dart run test --reporter expanded ``` -------------------------------- ### Centrifugo Configuration Example Source: https://github.com/centrifugal/centrifuge-dart/blob/master/example/flutter_app/README.md This JSON configuration is for the Centrifugo server. Ensure you create a 'chat' namespace with appropriate permissions for publishing, joining, leaving, and presence. ```json { "...": "", "allowed_origins": ["http://localhost:8000"], "namespaces": [ { "name": "chat", "anonymous": false, "publish": true, "join_leave": true, "presence": true, "presence_stats": true, "allow_publish_for_subscriber": true, "allow_subscribe_for_client": true } ] } ``` -------------------------------- ### Run Centrifugo with Admin Option Source: https://github.com/centrifugal/centrifuge-dart/blob/master/example/console/readme.md Start the Centrifugo server with the `--admin` flag enabled. This allows you to use the admin interface to send messages to connected clients, useful for testing. ```bash centrifugo --admin ``` -------------------------------- ### Running Centrifugo in Insecure Client Mode Source: https://github.com/centrifugal/centrifuge-dart/blob/master/example/flutter_app/README.md This command starts the Centrifugo server with a specified configuration file, enabling insecure client mode for easier testing and development. The `--admin` flag provides access to the admin interface. ```bash ./centrifugo --config config.json --client_insecure --admin ``` -------------------------------- ### Run Centrifugo in Insecure Client Mode Source: https://github.com/centrifugal/centrifuge-dart/blob/master/example/console/readme.md For testing purposes, run Centrifugo with both `--client_insecure` and `--admin` flags. This bypasses JWT token validation, simplifying initial setup and testing. ```bash centrifugo --client_insecure --admin ``` -------------------------------- ### Centrifugo Configuration for Chat Namespace Source: https://github.com/centrifugal/centrifuge-dart/blob/master/example/console/readme.md This JSON configuration enables a 'chat' namespace in Centrifugo, allowing anonymous subscriptions, publishing, and presence features. Ensure your Centrifugo server uses this or a similar configuration for the chat example to function correctly. ```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_stats": true, "allow_publish_for_subscriber": true, "allow_subscribe_for_client": true } ] } ``` -------------------------------- ### Generate Subscription JWT Token Source: https://github.com/centrifugal/centrifuge-dart/blob/master/example/console/readme.md Use this command to generate a JWT token for subscribing to the 'chat:index' channel for a user named 'dart'. This token grants the client permission to subscribe to specific channels. ```bash centrifugo gensubtoken --user dart --channel chat:index ``` -------------------------------- ### Run Flutter App on Chrome with Specific Port Source: https://github.com/centrifugal/centrifuge-dart/blob/master/example/chat_app/README.md Launch the Flutter chat application on the Chrome browser, specifying a web port. Ensure this port is whitelisted in your Centrifugo `config.json`. ```bash flutter run -d chrome --web-port 3000 ``` -------------------------------- ### Generate User JWT Token Source: https://github.com/centrifugal/centrifuge-dart/blob/master/example/console/readme.md Use this command to generate a JWT token for a user named 'dart'. This token is required for the client to authenticate with the Centrifugo server. ```bash centrifugo gentoken --user dart ``` -------------------------------- ### Publish Message via Centrifugo Admin Interface Source: https://github.com/centrifugal/centrifuge-dart/blob/master/example/console/readme.md Send a message to the 'chat:index' channel using the Centrifugo admin interface. This demonstrates how to publish data to clients connected to a specific channel. ```json { "message": "hello world", "username": "admin" } ``` -------------------------------- ### Register Service Worker in Chat App Source: https://github.com/centrifugal/centrifuge-dart/blob/master/example/chat_app/web/index.html This code registers the 'flutter_service_worker.js' when the window loads. Ensure the service worker file is correctly placed in the root directory. ```javascript if ('serviceWorker' in navigator) { window.addEventListener('load', function () { navigator.serviceWorker.register('flutter_service_worker.js'); }); } ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.