Class: Spacebunny::LiveStream::Message

Inherits:
Object
  • Object
show all
Defined in:
lib/spacebunny/live_stream/message.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(live_stream, options, delivery_info, metadata, payload) ⇒ Message

Returns a new instance of Message.



6
7
8
9
10
11
12
13
14
# File 'lib/spacebunny/live_stream/message.rb', line 6

def initialize(live_stream, options, delivery_info, , payload)
  @live_stream = live_stream
  @options = options
  @delivery_info = delivery_info
  @metadata = 
  @payload = payload

  set_sender_id_and_channel
end

Instance Attribute Details

#channel_nameObject (readonly)

Returns the value of attribute channel_name.



4
5
6
# File 'lib/spacebunny/live_stream/message.rb', line 4

def channel_name
  @channel_name
end

#delivery_infoObject (readonly)

Returns the value of attribute delivery_info.



4
5
6
# File 'lib/spacebunny/live_stream/message.rb', line 4

def delivery_info
  @delivery_info
end

#live_streamObject (readonly)

Returns the value of attribute live_stream.



4
5
6
# File 'lib/spacebunny/live_stream/message.rb', line 4

def live_stream
  @live_stream
end

#metadataObject (readonly)

Returns the value of attribute metadata.



4
5
6
# File 'lib/spacebunny/live_stream/message.rb', line 4

def 
  @metadata
end

#payloadObject (readonly)

Returns the value of attribute payload.



4
5
6
# File 'lib/spacebunny/live_stream/message.rb', line 4

def payload
  @payload
end

#sender_idObject (readonly)

Returns the value of attribute sender_id.



4
5
6
# File 'lib/spacebunny/live_stream/message.rb', line 4

def sender_id
  @sender_id
end

Instance Method Details

#ack(options = {}) ⇒ Object



16
17
18
19
# File 'lib/spacebunny/live_stream/message.rb', line 16

def ack(options = {})
  multiple = options.fetch :multiple, false
  @live_stream.acknowledge @delivery_info.delivery_tag, multiple
end

#from_api?Boolean

Returns:

  • (Boolean)


27
28
29
# File 'lib/spacebunny/live_stream/message.rb', line 27

def from_api?
  !@metadata[:headers].nil? && @metadata[:headers]['x-from-sb-api']
end

#nack(options = {}) ⇒ Object



21
22
23
24
25
# File 'lib/spacebunny/live_stream/message.rb', line 21

def nack(options = {})
  multiple = options.fetch :multiple, false
  requeue = options.fetch :requeue, false
  @live_stream.nack @delivery_info.delivery_tag, multiple, requeue
end