Method: Appium::Core::WebSocket#initialize
- Defined in:
- lib/appium_lib_core/common/ws/websocket.rb
#initialize(url:, protocols: nil, options: {}) ⇒ WebSocket
A websocket client based on Faye::WebSocket::Client . Uses eventmachine to wait response from the peer. The eventmachine works on a thread. The thread will exit with close method.
42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 |
# File 'lib/appium_lib_core/common/ws/websocket.rb', line 42 def initialize(url:, protocols: nil, options: {}) @endpoint = url @ws_thread = Thread.new do EM.run do @client ||= ::Faye::WebSocket::Client.new(url, protocols, ) @client.on :open do |_open| handle_open end @client.on :message do || (.data) end @client.on :error do |_error| handle_error end @client.on :close do |close| handle_close(close.code, close.reason) end end end end |