客户端库

用 Flutter 实现实时 WebSocket

支持 iOS、Android 与 Web 上的 Flutter 和 Dart 应用。

登录后,示例代码会自动填入您的集群主机。 登录

使用 AI 编程智能体? 复制 Agent 提示词 ↓

  1. 安装

    flutter pub add dart_pusher_channels
  2. 订阅频道

    final options = PusherChannelsOptions.fromHost(
      scheme: 'wss',
      host: 'ws.hibira.io',
      port: 443,
      key: 'YOUR_APP_KEY',
    );
    final client = PusherChannelsClient.websocket(
      options: options,
      connectionErrorHandler: (error, trace, refresh) => refresh(),
    );
    
    final channel = client.publicChannel('orders');
    channel.bind('order-shipped').listen((event) => print(event.data));
    client.onConnectionEstablished.listen((_) => channel.subscribeIfNotUnsubscribed());
    await client.connect();

Agent 提示词

将这段提示词粘贴到 Claude Code、Cursor、GitHub Copilot 或其他 AI 编程智能体,它会按照上方的设置,把 Hibira 接入您的 Flutter 项目。

请将 YOUR_APP_KEY 等占位符替换为控制台中的值,或让智能体保留为环境变量,之后再自行填写。

或连接 Hibira MCP 服务器,让代理自行创建应用并填入凭据。 连接您的 AI 编程代理 →

请使用控制台中的应用密钥(key 与 secret)。频道、事件与授权端点的用法与 Pusher 完全相同。 库参考文档 ↗