Class: WebSocketIO::Client
- Inherits:
-
Object
- Object
- WebSocketIO::Client
- Extended by:
- Forwardable
- Defined in:
- lib/websocketio/client.rb
Class Method Summary collapse
-
.eof? ⇒ Boolean
TODO: FilterIO assume that eof? isn’t blocking method.
Instance Method Summary collapse
- #close ⇒ Object
- #closed? ⇒ Boolean
-
#initialize(socket, handshake_args) ⇒ Client
constructor
A new instance of Client.
- #write(str) ⇒ Object
Constructor Details
#initialize(socket, handshake_args) ⇒ Client
Returns a new instance of Client.
13 14 15 16 17 18 19 20 21 22 23 24 25 |
# File 'lib/websocketio/client.rb', line 13 def initialize(socket, handshake_args) @socket = socket @handshake = WebSocket::Handshake::Client.new(handshake_args) @socket.write @handshake.to_s until @handshake.finished? do @handshake << @socket.getc end # TODO: FilterIO assume that eof? isn't blocking method. But TCPSocket#eof? is. # See http://docs.ruby-lang.org/en/2.2.0/IO.html#method-i-eof-3F def @socket.eof?; closed?; end @filtered_socket = filter(@socket, @handshake.version) end |
Class Method Details
.eof? ⇒ Boolean
TODO: FilterIO assume that eof? isn’t blocking method. But TCPSocket#eof? is. See docs.ruby-lang.org/en/2.2.0/IO.html#method-i-eof-3F
23 |
# File 'lib/websocketio/client.rb', line 23 def @socket.eof?; closed?; end |
Instance Method Details
#close ⇒ Object
27 28 29 30 31 32 |
# File 'lib/websocketio/client.rb', line 27 def close send_frame type: :close @socket.close @socket = nil @closed = true end |
#closed? ⇒ Boolean
34 35 36 |
# File 'lib/websocketio/client.rb', line 34 def closed? @closed end |
#write(str) ⇒ Object
38 39 40 41 |
# File 'lib/websocketio/client.rb', line 38 def write(str) send_frame data: str str.to_s.bytesize end |