Class: Volt::ChannelStub
- Includes:
- Eventable
- Defined in:
- lib/volt/page/channel_stub.rb
Overview
Behaves the same as the Channel class, only the Channel class uses sockjs to pass messages to the backend. ChannelStub, simply passes them directly to SocketConnectionHandlerStub.
Instance Attribute Summary collapse
-
#error ⇒ Object
readonly
Returns the value of attribute error.
-
#reconnect_interval ⇒ Object
readonly
Returns the value of attribute reconnect_interval.
-
#state ⇒ Object
readonly
Returns the value of attribute state.
Instance Method Summary collapse
- #close! ⇒ Object
-
#initialize ⇒ ChannelStub
constructor
A new instance of ChannelStub.
- #message_received(*message) ⇒ Object
- #opened ⇒ Object
- #send_message(message) ⇒ Object
Methods included from Eventable
#on, #remove_listener, #trigger!
Constructor Details
#initialize ⇒ ChannelStub
Returns a new instance of ChannelStub.
16 17 18 |
# File 'lib/volt/page/channel_stub.rb', line 16 def initialize @state = :connected end |
Instance Attribute Details
#error ⇒ Object (readonly)
Returns the value of attribute error.
14 15 16 |
# File 'lib/volt/page/channel_stub.rb', line 14 def error @error end |
#reconnect_interval ⇒ Object (readonly)
Returns the value of attribute reconnect_interval.
14 15 16 |
# File 'lib/volt/page/channel_stub.rb', line 14 def reconnect_interval @reconnect_interval end |
#state ⇒ Object (readonly)
Returns the value of attribute state.
14 15 16 |
# File 'lib/volt/page/channel_stub.rb', line 14 def state @state end |
Instance Method Details
#close! ⇒ Object
33 34 35 |
# File 'lib/volt/page/channel_stub.rb', line 33 def close! fail 'close! should not be called on the backend channel' end |
#message_received(*message) ⇒ Object
25 26 27 |
# File 'lib/volt/page/channel_stub.rb', line 25 def (*) trigger!('message', *) end |
#opened ⇒ Object
20 21 22 23 |
# File 'lib/volt/page/channel_stub.rb', line 20 def opened trigger!('open') trigger!('changed') end |
#send_message(message) ⇒ Object
29 30 31 |
# File 'lib/volt/page/channel_stub.rb', line 29 def () SocketConnectionHandlerStub.new(self).() end |