Class: Streamforce::Message
- Inherits:
-
Object
- Object
- Streamforce::Message
- Defined in:
- lib/streamforce/message.rb
Instance Method Summary collapse
- #channel ⇒ Object
- #channel_name ⇒ Object
- #channel_type ⇒ Object
- #client_id ⇒ Object
- #data ⇒ Object
- #error_message ⇒ Object
- #id ⇒ Object
-
#initialize(payload) ⇒ Message
constructor
A new instance of Message.
- #no_replay? ⇒ Boolean
- #replay_available_messages? ⇒ Boolean
- #replay_from_message? ⇒ Boolean
- #replay_id ⇒ Object
- #subscription ⇒ Object
- #subscription? ⇒ Boolean
- #success? ⇒ Boolean
Constructor Details
#initialize(payload) ⇒ Message
Returns a new instance of Message.
2 3 4 |
# File 'lib/streamforce/message.rb', line 2 def initialize(payload) @payload = payload end |
Instance Method Details
#channel ⇒ Object
18 19 20 |
# File 'lib/streamforce/message.rb', line 18 def channel @payload["channel"] end |
#channel_name ⇒ Object
26 27 28 |
# File 'lib/streamforce/message.rb', line 26 def channel_name channel.split("/")[2] end |
#channel_type ⇒ Object
22 23 24 |
# File 'lib/streamforce/message.rb', line 22 def channel_type channel.split("/")[1] end |
#client_id ⇒ Object
6 7 8 |
# File 'lib/streamforce/message.rb', line 6 def client_id @payload["clientId"] end |
#data ⇒ Object
34 35 36 |
# File 'lib/streamforce/message.rb', line 34 def data @payload["data"] end |
#error_message ⇒ Object
58 59 60 |
# File 'lib/streamforce/message.rb', line 58 def @payload["error"] end |
#id ⇒ Object
10 11 12 |
# File 'lib/streamforce/message.rb', line 10 def id @payload["id"] end |
#no_replay? ⇒ Boolean
54 55 56 |
# File 'lib/streamforce/message.rb', line 54 def no_replay? replay_id.nil? || replay_id == -1 end |
#replay_available_messages? ⇒ Boolean
50 51 52 |
# File 'lib/streamforce/message.rb', line 50 def replay_id == -2 end |
#replay_from_message? ⇒ Boolean
46 47 48 |
# File 'lib/streamforce/message.rb', line 46 def replay_id && replay_id != -1 && replay_id != -2 end |
#replay_id ⇒ Object
14 15 16 |
# File 'lib/streamforce/message.rb', line 14 def replay_id @payload.dig "ext", "replay", subscription end |
#subscription ⇒ Object
38 39 40 |
# File 'lib/streamforce/message.rb', line 38 def subscription @payload["subscription"] end |
#subscription? ⇒ Boolean
42 43 44 |
# File 'lib/streamforce/message.rb', line 42 def subscription? channel == "/meta/subscribe" end |
#success? ⇒ Boolean
30 31 32 |
# File 'lib/streamforce/message.rb', line 30 def success? @payload["successful"] end |