Class: Mbeditor::CollaborationChannel
- Inherits:
-
Object
- Object
- Mbeditor::CollaborationChannel
show all
- Includes:
- ChannelAuthentication
- Defined in:
- app/channels/mbeditor/collaboration_channel.rb
Overview
Per-file relay edge for realtime collaborative editing. The channel never
interprets the opaque Yjs bytes it carries — it persists them through
CollaborationDocStore and relays them to the other subscribers on a stream
keyed by a digest of the workspace-relative path. It degrades gracefully
when ActionCable is absent, matching the EditorChannel conditional-base
pattern.
Constant Summary
collapse
- STREAM_PREFIX =
"mbeditor_collab"
Instance Method Summary
collapse
#mbeditor_auth_hook, #mbeditor_authenticated?, #mbeditor_log_denial
Instance Method Details
#awareness(data) ⇒ Object
47
48
49
50
51
52
|
# File 'app/channels/mbeditor/collaboration_channel.rb', line 47
def awareness(data)
bytes = data["awareness"]
return if bytes.nil?
relay("type" => "awareness", "awareness" => bytes)
end
|
#doc_update(data) ⇒ Object
31
32
33
34
35
36
37
|
# File 'app/channels/mbeditor/collaboration_channel.rb', line 31
def doc_update(data)
bytes = data["update"]
return if bytes.nil?
CollaborationDocStore.record_update(room_key, bytes)
relay("type" => "doc_update", "update" => bytes)
end
|
#snapshot(data) ⇒ Object
39
40
41
42
43
44
45
|
# File 'app/channels/mbeditor/collaboration_channel.rb', line 39
def snapshot(data)
bytes = data["snapshot"]
return if bytes.nil?
CollaborationDocStore.replace_snapshot(room_key, bytes)
relay("type" => "snapshot", "snapshot" => bytes)
end
|
#subscribed ⇒ Object
17
18
19
20
21
22
23
24
25
|
# File 'app/channels/mbeditor/collaboration_channel.rb', line 17
def subscribed
return unless mbeditor_authenticated?
@path = params[:path].to_s
return reject if @path.empty? && respond_to?(:reject, true)
stream_from stream_name if respond_to?(:stream_from)
transmit_initial_state
end
|
#unsubscribed ⇒ Object
27
28
29
|
# File 'app/channels/mbeditor/collaboration_channel.rb', line 27
def unsubscribed
end
|