Class: PageWebSocket
Instance Attribute Summary
#latency
Instance Method Summary
collapse
#on_message, #send, #send_all, #send_others, #simulate_latency
Constructor Details
#initialize(ws, options = {}) ⇒ PageWebSocket
Returns a new instance of PageWebSocket.
5
6
7
8
9
10
11
|
# File 'lib/sinatra/liveviews/page-websocket.rb', line 5
def initialize(ws, options = {})
super(ws)
@app = options[:app]
@url = options[:url]
end
|
Instance Method Details
#document ⇒ Object
33
34
35
36
37
38
39
40
|
# 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 ⇒ Object
29
30
31
|
# File 'lib/sinatra/liveviews/page-websocket.rb', line 29
def on_close
super
end
|
#on_open ⇒ Object
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
|
# 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
self.send 'message', { :content => "no live handler for #{path}" }
end
end
|