Class: Riddl::Protocols::WebSocket
- Inherits:
-
EventMachine::WebSocket::Connection
- Object
- EventMachine::WebSocket::Connection
- Riddl::Protocols::WebSocket
show all
- Defined in:
- lib/ruby/riddl/protocols/websocket.rb
Defined Under Namespace
Classes: Error, ParserData
Class Method Summary
collapse
Instance Method Summary
collapse
Constructor Details
#initialize(app, socket) ⇒ WebSocket
Returns a new instance of WebSocket.
92
93
94
95
96
97
98
99
|
# File 'lib/ruby/riddl/protocols/websocket.rb', line 92
def initialize(app, socket)
@app = app
@socket = socket
@ssl = socket.backend.respond_to?(:ssl?) && socket.backend.ssl?
@closed = true
socket.websocket = self
socket.comm_inactivity_timeout = 0
end
|
Class Method Details
.new(*args) ⇒ Object
68
69
70
71
72
|
# File 'lib/ruby/riddl/protocols/websocket.rb', line 68
def self.new(*args)
instance = allocate
instance.__send__(:initialize, *args)
instance
end
|
Instance Method Details
#close_connection(*args) ⇒ Object
80
81
82
83
84
85
|
# File 'lib/ruby/riddl/protocols/websocket.rb', line 80
def close_connection(*args)
EM.next_tick do
trigger_on_close
@socket.close_connection(*args)
end
end
|
#closed? ⇒ Boolean
101
102
103
|
# File 'lib/ruby/riddl/protocols/websocket.rb', line 101
def closed?
@closed
end
|
#send_data(*args) ⇒ Object
74
75
76
77
78
|
# File 'lib/ruby/riddl/protocols/websocket.rb', line 74
def send_data(*args)
EM.next_tick do
@socket.send_data(*args)
end
end
|
#trigger_on_close ⇒ Object
89
|
# File 'lib/ruby/riddl/protocols/websocket.rb', line 89
def trigger_on_close; @closed = true; @app.onclose; end
|
#trigger_on_error(error) ⇒ Object
90
|
# File 'lib/ruby/riddl/protocols/websocket.rb', line 90
def trigger_on_error(error); @closed = true; @app.onerror(error); true; end
|
#trigger_on_message(msg) ⇒ Object
87
|
# File 'lib/ruby/riddl/protocols/websocket.rb', line 87
def trigger_on_message(msg); @app.onmessage(msg); end
|
#trigger_on_open(handshake) ⇒ Object
88
|
# File 'lib/ruby/riddl/protocols/websocket.rb', line 88
def trigger_on_open(handshake); @closed = false; @app.onopen; end
|