realtime
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChineseRealtime — WebSocket Communication
实时通信 — WebSocket 通信
Sails provides two tiers of realtime support via sails-hook-sockets: low-level room-based messaging () and high-level model-centric notifications (Resourceful PubSub). Both use Socket.IO under the hood and integrate seamlessly with Sails' request lifecycle.
sails.socketsSails 通过 sails-hook-sockets 提供两层实时通信支持:基于房间的底层消息传递()以及以模型为中心的高层通知(Resourceful PubSub)。两者均底层基于 Socket.IO 实现,并与 Sails 的请求生命周期无缝集成。
sails.socketsWhen to Use
适用场景
Use this skill when:
- Building chat, messaging, or collaborative features
- Sending live notifications to specific users or groups
- Broadcasting model changes (created, updated, destroyed) to subscribers
- Tracking online presence or user status
- Creating live dashboards with auto-updating data
- Configuring WebSocket security, Redis adapters, or multi-server deployment
- Integrating sails.io.js with React, Vue, or Svelte frontends
在以下场景中可使用该技能:
- 构建聊天、消息传递或协作类功能
- 向特定用户或群组发送实时通知
- 向订阅者广播模型变更(创建、更新、删除)
- 追踪在线状态或用户状态
- 创建具备自动更新数据的实时仪表盘
- 配置 WebSocket 安全策略、Redis 适配器或多服务器部署
- 将 sails.io.js 与 React、Vue 或 Svelte 前端集成
Rules
规则说明
Read individual rule files for detailed explanations and code examples:
- rules/getting-started.md - What realtime means in Sails, two-tier architecture, setup
- rules/sails-sockets.md - Low-level API: rooms, broadcast, blast
sails.sockets - rules/resourceful-pubsub.md - High-level model API: subscribe, publish, unsubscribe
- rules/client-side.md - sails.io.js client library and frontend integration
- rules/configuration.md - , Redis adapter, security, lifecycle
config/sockets.js - rules/patterns.md - Chat rooms, notifications, presence, live dashboards
阅读单个规则文件以获取详细说明和代码示例:
- rules/getting-started.md - Sails 中实时通信的定义、双层架构、设置方法
- rules/sails-sockets.md - 底层 API:房间、广播、全量推送
sails.sockets - rules/resourceful-pubsub.md - 高层模型 API:订阅、发布、取消订阅
- rules/client-side.md - sails.io.js 客户端库与前端集成
- rules/configuration.md - 、Redis 适配器、安全配置、生命周期
config/sockets.js - rules/patterns.md - 聊天室、通知、在线状态、实时仪表盘