Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
张重言
rails
提交
005a99eb
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,发现更多精彩内容 >>
提交
005a99eb
编写于
4月 09, 2015
作者:
P
Pratik Naik
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Rename Registry to InternalChannel and remove dup methods
上级
a29034e4
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
16 addition
and
32 deletion
+16
-32
lib/action_cable/connection.rb
lib/action_cable/connection.rb
+1
-1
lib/action_cable/connection/base.rb
lib/action_cable/connection/base.rb
+10
-3
lib/action_cable/connection/internal_channel.rb
lib/action_cable/connection/internal_channel.rb
+5
-28
未找到文件。
lib/action_cable/connection.rb
浏览文件 @
005a99eb
module
ActionCable
module
Connection
autoload
:Base
,
'action_cable/connection/base'
autoload
:
Registry
,
'action_cable/connection/registry
'
autoload
:
InternalChannel
,
'action_cable/connection/internal_channel
'
autoload
:Identifier
,
'action_cable/connection/identifier'
end
end
lib/action_cable/connection/base.rb
浏览文件 @
005a99eb
module
ActionCable
module
Connection
class
Base
include
Registry
include
InternalChannel
,
Identifier
PING_INTERVAL
=
3
class_attribute
:identifiers
self
.
identifiers
=
Set
.
new
def
self
.
identified_by
(
*
identifiers
)
self
.
identifiers
+=
identifiers
end
attr_reader
:env
,
:server
delegate
:worker_pool
,
:pubsub
,
:logger
,
to: :server
...
...
@@ -89,7 +96,7 @@ def handle_exception
private
def
initialize_connection
connect
if
respond_to?
(
:connect
)
register_connection
subscribe_to_internal_channel
@accept_messages
=
true
worker_pool
.
async
.
invoke
(
self
,
:received_data
,
@pending_messages
.
shift
)
until
@pending_messages
.
empty?
...
...
@@ -97,7 +104,7 @@ def initialize_connection
def
on_connection_closed
cleanup_subscriptions
cleanup_internal_redis_subscriptions
unsubscribe_from_internal_channel
disconnect
if
respond_to?
(
:disconnect
)
end
...
...
lib/action_cable/connection/
registry
.rb
→
lib/action_cable/connection/
internal_channel
.rb
浏览文件 @
005a99eb
module
ActionCable
module
Connection
module
Registry
module
InternalChannel
extend
ActiveSupport
::
Concern
included
do
class_attribute
:identifiers
self
.
identifiers
=
Set
.
new
end
module
ClassMethods
def
identified_by
(
*
identifiers
)
self
.
identifiers
+=
identifiers
end
end
def
register_connection
def
subscribe_to_internal_channel
if
connection_identifier
.
present?
callback
=
->
(
message
)
{
process_
registry
_message
(
message
)
}
callback
=
->
(
message
)
{
process_
internal
_message
(
message
)
}
@_internal_redis_subscriptions
||=
[]
@_internal_redis_subscriptions
<<
[
internal_redis_channel
,
callback
]
...
...
@@ -25,26 +14,14 @@ def register_connection
end
end
def
internal_redis_channel
"action_cable/
#{
connection_identifier
}
"
end
def
connection_identifier
@connection_identifier
||=
connection_gid
identifiers
.
map
{
|
id
|
instance_variable_get
(
"@
#{
id
}
"
)}
end
def
connection_gid
(
ids
)
ids
.
map
{
|
o
|
o
.
to_global_id
.
to_s
}.
sort
.
join
(
":"
)
end
def
cleanup_internal_redis_subscriptions
def
unsubscribe_from_internal_channel
if
@_internal_redis_subscriptions
.
present?
@_internal_redis_subscriptions
.
each
{
|
channel
,
callback
|
pubsub
.
unsubscribe_proc
(
channel
,
callback
)
}
end
end
private
def
process_
registry
_message
(
message
)
def
process_
internal
_message
(
message
)
message
=
ActiveSupport
::
JSON
.
decode
(
message
)
case
message
[
'type'
]
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录