Module: Wands::JavaScript::WebSocket::ClassMethods
- Defined in:
- lib/wands/java_script/web_socket.rb
Overview
The class methods module
Instance Method Summary collapse
Instance Method Details
#open(host, port) ⇒ Object
17 18 19 20 21 22 23 24 25 26 |
# File 'lib/wands/java_script/web_socket.rb', line 17 def open(host, port) uri = URI::HTTP.build(host:, port:) ws = JS.global[:WebSocket].new(uri.to_s) ws[:binaryType] = "arraybuffer" instance = new(ws) ws.addEventListener("message") { instance << it } wait_until_ready ws instance end |