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 =
30.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
51 52 53 54 55 56 57 58 |
# File 'lib/cable_room/room/port_management.rb', line 51 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
46 47 48 49 |
# File 'lib/cable_room/room/port_management.rb', line 46 def initialize(...) super @_port_clients = {} end |
#reply(message = nil, **kwargs) ⇒ Object
60 61 62 63 64 65 66 67 68 69 70 71 72 |
# File 'lib/cable_room/room/port_management.rb', line 60 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 |