Class: Tep::BroadcastSubscription

Inherits:
Object
  • Object
show all
Defined in:
lib/tep/broadcast_subscription.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(topic, fd, mode) ⇒ BroadcastSubscription

Returns a new instance of BroadcastSubscription.



36
37
38
39
40
# File 'lib/tep/broadcast_subscription.rb', line 36

def initialize(topic, fd, mode)
  @topic = topic
  @fd    = fd
  @mode  = mode
end

Instance Attribute Details

#fdObject (readonly)

Integer file descriptor



22
23
24
# File 'lib/tep/broadcast_subscription.rb', line 22

def fd
  @fd
end

#modeObject (readonly)

Delivery mode controls how Tep::Broadcast.publish writes ‘payload` to `fd`:

0 = raw bytes (Sock.sphttp_write_str). The default; suits
    SSE / log fan-out / anything that doesn't need framing.
1 = WebSocket TEXT frame (Tep::WebSocket::OPCODE_TEXT).
2 = WebSocket BINARY frame (Tep::WebSocket::OPCODE_BINARY).

Modes 1 and 2 route through Tep::WebSocket::Driver.send_frame, so payloads land as proper WS frames the peer will accept. Apps register mode-1 subscriptions via subscribe_ws.



34
35
36
# File 'lib/tep/broadcast_subscription.rb', line 34

def mode
  @mode
end

#topicObject (readonly)

String



21
22
23
# File 'lib/tep/broadcast_subscription.rb', line 21

def topic
  @topic
end