Class: WebSocket::Handshake::Client
- Defined in:
- lib/websocket/handshake/client.rb
Overview
Construct or parse a client WebSocket handshake.
Instance Attribute Summary
Attributes inherited from Base
#error, #host, #path, #port, #query, #secure, #state, #version
Instance Method Summary collapse
-
#<<(data) ⇒ Object
Add text of response from Server.
-
#initialize(args = {}) ⇒ Client
constructor
Initialize new WebSocket Client.
-
#should_respond? ⇒ Boolean
Should send content to server after finished parsing?.
Methods inherited from Base
#finished?, #inspect, #leftovers, #to_s, #uri, #valid?
Constructor Details
#initialize(args = {}) ⇒ Client
Initialize new WebSocket Client
52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 |
# File 'lib/websocket/handshake/client.rb', line 52 def initialize(args = {}) super @version = args[:version] || DEFAULT_VERSION @origin = args[:origin] if args[:url] || args[:uri] uri = URI.parse(args[:url] || args[:uri]) @secure = (uri.scheme == 'wss') @host = uri.host @port = uri.port @path = uri.path @query = uri.query end @secure = args[:secure] if args[:secure] @host = args[:host] if args[:host] @port = args[:port] if args[:port] @path = args[:path] if args[:path] @query = args[:query] if args[:query] @path = '/' if @path.nil? || @path.empty? set_error(:no_host_provided) unless @host include_version end |
Instance Method Details
#<<(data) ⇒ Object
Add text of response from Server. This method will parse content immediately and update state and error(if neccessary)
92 93 94 95 96 97 |
# File 'lib/websocket/handshake/client.rb', line 92 def <<(data) @data << data if parse_data end end |
#should_respond? ⇒ Boolean
Should send content to server after finished parsing?
101 102 103 |
# File 'lib/websocket/handshake/client.rb', line 101 def should_respond? false end |