Sha256: 196737c898b759423d8254a3d9324efb7598ddcb4a9679d6bc0fffdd07e4ffe7

Contents?: true

Size: 871 Bytes

Versions: 6

Compression:

Stored size: 871 Bytes

Contents

# Acts the same as the Channel class on the front-end, but calls
# directly instead of using sockjs.

require 'volt/reactive/events'
require 'volt/tasks/dispatcher'

# 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 ChannelHandlerStub.
class ChannelStub
  include ReactiveTags

  attr_reader :state, :error, :reconnect_interval
  
  def initiailze
    @state = :connected
  end
  
  def opened
    trigger!('open')
    trigger!('changed')
  end
  
  def message_received(*message)
    trigger!('message', nil, *message)
  end
  
  tag_method(:send_message) do
    destructive!
  end
  def send_message(message)
    ChannelHandlerStub.new(self).process_message(message)
  end
  
  def close!
    raise "close! should not be called on the backend channel"
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
volt-0.4.7 lib/volt/page/channel_stub.rb
volt-0.4.5 lib/volt/page/channel_stub.rb
volt-0.4.4 lib/volt/page/channel_stub.rb
volt-0.4.3 lib/volt/page/channel_stub.rb
volt-0.4.2 lib/volt/page/channel_stub.rb
volt-0.4.1 lib/volt/page/channel_stub.rb