FLUTTER ECOSYSTEM

namiwang/actioncable_dart

Dart 中的 actioncable 客戶端,適用於純 Dart 或 Flutter 項目

actioncable_dart 專案封面
Stars
26
Forks
30
最近推送(UTC)
2024年10月25日
專案狀態
未封存
Nami W GitHub avatar
GITHUB User

Nami W ↗

@MoonshotAI , ex-@Microsoft. AI Infra, indie games, compilers, with ruby, typescript, and rust.

@MoonshotAI
語言Dart

技術主題

此儲存庫發佈的套件

使用的依賴

依賴清單 2 項

原始 README

以下為英文專案原文快照,最新內容請造訪 GitHub。

展開 / 收合專案 README

Pub

All Contributors

ActionCable in Dart

ActionCable is the default realtime websocket framework and protocol in Rails.

This is a dart port of the client and protocol implementation which is available in web, dartVM and flutter.

Usage

Connecting to a channel 🙌
cable = ActionCable.connect(
  "ws://10.0.2.2:3000/cable",
  headers: {
    "Authorization": "Some Token",
  },
  onConnected: (){
    print("connected");
  },
  onConnectionLost: () {
    print("connection lost");
  },
  onCannotConnect: () {
    print("cannot connect");
});
Subscribing to channel 🎉
cable.subscribe(
  "Chat", // either "Chat" and "ChatChannel" is fine
  channelParams: { "room": "private" },
  onSubscribed: (){}, // `confirm_subscription` received
  onDisconnected: (){}, // `disconnect` received
  onMessage: (Map message) {} // any other message received
);
Unsubscribing from a channel 🎃
cable.unsubscribe(
  "Chat", // either "Chat" and "ChatChannel" is fine
  {"room": "private"}
);
Perform an action on your ActionCable server 🎇

Requires that you have a method defined in your Rails Action Cable channel whose name matches the action property passed in.

cable.performAction(
  "Chat",
  action: "send_message",
  channelParams: { "room": "private" },
  actionParams: { "message": "Hello private peeps! 😜" }
);
Disconnect from the ActionCable server
cable.disconnect();

ActionCable protocol

Anycable has a great doc on that topic.

Contributors ✨

Thanks goes to these wonderful people (emoji key):

https://avatars1.githubusercontent.com/u/18232142?v=4?s=100
Clinton

💻 ⚠️
https://avatars0.githubusercontent.com/u/6298868?v=4?s=100
Hamad AlGhanim

💻
https://avatars.githubusercontent.com/u/498161?v=4?s=100
Fareesh Vijayarangam

💻

This project follows the all-contributors specification. Contributions of any kind welcome!