| 文件 | 最后提交记录 | 最后更新时间 |
|---|---|---|
| 4 个月前 | ||
| 4 个月前 | ||
| 25 天前 | ||
| 4 个月前 |
Chat Room (Rust)
Example project demonstrating real-time messaging and actor state management in Rust. This is the Rust translation of the chat-room example.
Getting Started
git clone https://github.com/rivet-dev/rivet.git
cd rivet/examples/chat-room-rust
cargo build -p rivet-engine
RIVET_ENGINE_BINARY_PATH=../../target/debug/rivet-engine cargo run
See the Rust Quickstart for creating the actor and connecting clients.
Features
- Real-time messaging: Broadcast messages to all connected clients instantly
- Persistent chat history: Messages stored in actor SQLite across restarts
- Persistent actor state: A framework-managed
Statevalue tracks message stats - Multiple chat rooms: Each room key is a separate actor instance with isolated state
- Event-driven architecture: Use actor events to push updates to clients in real-time
Implementation
The chat room demonstrates core Rivet Actor patterns for real-time communication:
- Actor Definition (
src/lib.rs): Defines thechatRoomactor with SQLite-backed message history, persisted stats,sendMessage/getHistory/getStatsactions, and anewMessageevent
Resources
Read more about actions, state, and events.
License
MIT