Class: Volt::ChannelStub

Inherits:
Object show all
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

Instance Method Summary collapse

Methods included from Eventable

#on, #remove_listener, #trigger!

Constructor Details

#initializeChannelStub

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

#errorObject (readonly)

Returns the value of attribute error.



14
15
16
# File 'lib/volt/page/channel_stub.rb', line 14

def error
  @error
end

#reconnect_intervalObject (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

#stateObject (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 message_received(*message)
  trigger!('message', *message)
end

#openedObject



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 send_message(message)
  SocketConnectionHandlerStub.new(self).process_message(message)
end