Module: CableRoom::Room::PortManagement
- Extended by:
- ActiveSupport::Concern
- Included in:
- Base
- Defined in:
- lib/cable_room/room/port_management.rb
Defined Under Namespace
Classes: PortClient
Constant Summary collapse
- PORT_TIMEOUT =
A port that the room has not heard from for this long is dropped. Any inbound message counts as hearing from it (see the receive_message callback below), and members only ping when they have been otherwise silent for RoomMember::PING_INTERVAL, so the longest gap a live member produces is 2 x PING_INTERVAL. Keep this comfortably above that: under load the room processes its queue late, and a reaped port is a lost student.
45.seconds
Instance Method Summary collapse
- #_apply_port_scope(client_port: nil, tag: nil, **kwargs) ⇒ Object
- #initialize ⇒ Object
- #reply(message = nil, **kwargs) ⇒ Object
Instance Method Details
#_apply_port_scope(client_port: nil, tag: nil, **kwargs) ⇒ Object
62 63 64 65 66 67 68 69 |
# File 'lib/cable_room/room/port_management.rb', line 62 def _apply_port_scope(client_port: nil, tag: nil, **kwargs) if client_port && tag client_port = resolve_client_port(client_port) throw :abort unless client_port && (client_port[:tags]&.include?(tag) || client_port[:as] == tag) end { client_port: client_port || tag, **kwargs } end |
#initialize ⇒ Object
57 58 59 60 |
# File 'lib/cable_room/room/port_management.rb', line 57 def initialize(...) super @_port_clients = {} end |
#reply(message = nil, **kwargs) ⇒ Object
71 72 73 74 75 76 77 78 79 80 81 82 83 |
# File 'lib/cable_room/room/port_management.rb', line 71 def reply( = nil, **kwargs) raise ArgumentError, "Can only use reply when handling a message" unless raise ArgumentError, "Must provide message or block" unless || block_given? raise ArgumentError, "Cannot specify client_port: when using reply" if kwargs.key?(:client_port) if block_given? with_port_scope(client_port: ) do yield end else broadcast(, **kwargs, client_port: ) end end |