class PageWebSocket
Public Class Methods
new(ws, options = {})
click to toggle source
Calls superclass method
WebSocketHelper::new
# File lib/sinatra/liveviews/page-websocket.rb, line 5 def initialize(ws, options = {}) super(ws) # todo: validate the url and the app instances @app = options[:app] @url = options[:url] end
Public Instance Methods
document()
click to toggle source
# File lib/sinatra/liveviews/page-websocket.rb, line 33 def document if @document.nil? @document = ClientDocument.new(self) @document.location = @url end return @document end
on_close()
click to toggle source
Calls superclass method
WebSocketHelper#on_close
# File lib/sinatra/liveviews/page-websocket.rb, line 29 def on_close super end
on_open()
click to toggle source
Calls superclass method
WebSocketHelper#on_open
# File lib/sinatra/liveviews/page-websocket.rb, line 13 def on_open super uri = URI.parse(@url) path = uri.path method_name = @app.class._method_name('LIVE', path) if @app.respond_to? method_name @app.send(method_name, document) else # send an error back to the client self.send 'message', { :content => "no live handler for #{path}" } end end