Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
张重言
rails
提交
71002cfb
R
rails
项目概览
张重言
/
rails
通知
1
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
R
rails
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
前往新版Gitcode,体验更适合开发者的 AI 搜索 >>
未验证
提交
71002cfb
编写于
8月 17, 2020
作者:
J
Jonathan Hefner
提交者:
GitHub
8月 17, 2020
浏览文件
操作
浏览文件
下载
差异文件
Merge pull request #40062 from p8/guides/actioncable-terminology
Use headings to make Action Cable terminology more clear [skip ci]
上级
1e0f5118
6217244b
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
29 addition
and
15 deletion
+29
-15
guides/source/action_cable_overview.md
guides/source/action_cable_overview.md
+29
-15
未找到文件。
guides/source/action_cable_overview.md
浏览文件 @
71002cfb
...
...
@@ -30,35 +30,40 @@ choice.
Terminology
-----------
Action Cable uses WebSockets instead of the HTTP request-response protocol.
Both Action Cable and WebSockets introduce some less familiar terminology:
### Connections
*Connections*
form the foundation of the client-server relationship.
A single Action Cable server can handle multiple connection instances. It has one
connection instance per WebSocket connection. A single user may have multiple
WebSockets open to your application if they use multiple browser tabs or devices.
The client of a WebSocket connection is called the consumer.
Each consumer can in turn subscribe to multiple channels. Each channel
### Consumers
The client of a WebSocket connection is called the
*consumer*
. In Action Cable
the consumer is created by the client-side JavaScript framework.
### Channels
Each consumer can in turn subscribe to multiple
*channels*
. Each channel
encapsulates a logical unit of work, similar to what a controller does in
a regular MVC setup. For example, you could have a
`ChatChannel`
and
an
`AppearancesChannel`
, and a consumer could be subscribed to either
or to both of these channels. At the very least, a consumer should be subscribed
to one channel.
When the consumer is subscribed to a channel, they act as a subscriber.
### Subscribers
When the consumer is subscribed to a channel, they act as a
*subscriber*
.
The connection between the subscriber and the channel is, surprise-surprise,
called a subscription. A consumer can act as a subscriber to a given channel
any number of times. For example, a consumer could subscribe to multiple chat rooms
at the same time. (And remember that a physical user may have multiple consumers,
one per tab/device open to your connection).
Each channel can then again be streaming zero or more broadcastings.
A broadcasting is a pubsub link where anything transmitted by the broadcaster is
sent directly to the channel subscribers who are streaming that named broadcasting.
As you can see, this is a fairly deep architectural stack. There's a lot of new
terminology to identify the new pieces, and on top of that, you're dealing
with both client and server side reflections of each unit.
What is Pub/Sub?
----------------
### Pub/Sub
[
Pub/Sub
](
https://en.wikipedia.org/wiki/Publish%E2%80%93subscribe_pattern
)
, or
Publish-Subscribe, refers to a message queue paradigm whereby senders of
...
...
@@ -66,12 +71,21 @@ information (publishers), send data to an abstract class of recipients
(subscribers), without specifying individual recipients. Action Cable uses this
approach to communicate between the server and many clients.
### Broadcastings
A broadcasting is a pub/sub link where anything transmitted by the broadcaster is
sent directly to the channel subscribers who are streaming that named broadcasting.
Each channel can be streaming zero or more broadcastings.
As you can see, this is a fairly deep architectural stack. There's a lot of new
terminology to identify the new pieces, and on top of that, you're dealing
with both client and server side reflections of each unit.
## Server-Side Components
### Connections
*Connections*
form the foundation of the client-server relationship. For every
WebSocket accepted by the server, a connection object is instantiated. This
For every WebSocket accepted by the server, a connection object is instantiated. This
object becomes the parent of all the
*channel subscriptions*
that are created
from there on. The connection itself does not deal with any specific application
logic beyond authentication and authorization. The client of a WebSocket
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录