Method: Appium::Core::WebSocket#close

Defined in:
lib/appium_lib_core/common/ws/websocket.rb

#close(code: nil, reason: 'close from ruby_lib_core') ⇒ Object

Closes the connection, sending the given status code and reason text, both of which are optional.

Examples:

ws = WebSocket.new(url: "ws://#{host}:#{port}/ws/session/#{@session_id}/appium/device/logcat")
ws.close reason: 'a something special reason'

Parameters:

  • (defaults to: nil)

    A status code to send to the peer with close signal. Default is nil.

  • (defaults to: 'close from ruby_lib_core')

    A reason to send to the peer with close signal. Default is ‘close from ruby_lib_core’.



106
107
108
109
110
111
112
113
# File 'lib/appium_lib_core/common/ws/websocket.rb', line 106

def close(code: nil, reason: 'close from ruby_lib_core')
  if @client.nil?
    ::Appium::Logger.warn 'Websocket was closed'
  else
    @client.close code, reason
  end
  @ws_thread.exit
end