Class: Hop::WssBearer::BufferedSocket
- Inherits:
-
Object
- Object
- Hop::WssBearer::BufferedSocket
- Defined in:
- lib/hop/wss_bearer.rb
Instance Method Summary collapse
- #close ⇒ Object
-
#initialize(sock, initial) ⇒ BufferedSocket
constructor
A new instance of BufferedSocket.
- #read_nonblock(n, exception: true) ⇒ Object
- #to_io ⇒ Object
- #write_nonblock(data, exception: true) ⇒ Object
Constructor Details
#initialize(sock, initial) ⇒ BufferedSocket
Returns a new instance of BufferedSocket.
383 384 385 386 |
# File 'lib/hop/wss_bearer.rb', line 383 def initialize(sock, initial) @sock = sock @buffer = initial end |
Instance Method Details
#close ⇒ Object
399 |
# File 'lib/hop/wss_bearer.rb', line 399 def close = @sock.close |
#read_nonblock(n, exception: true) ⇒ Object
388 389 390 391 392 393 394 395 |
# File 'lib/hop/wss_bearer.rb', line 388 def read_nonblock(n, exception: true) unless @buffer.empty? chunk = @buffer.byteslice(0, n) @buffer = @buffer.byteslice(chunk.bytesize..) || "".b return chunk end @sock.read_nonblock(n, exception: exception) end |
#to_io ⇒ Object
398 |
# File 'lib/hop/wss_bearer.rb', line 398 def to_io = @sock.to_io |
#write_nonblock(data, exception: true) ⇒ Object
397 |
# File 'lib/hop/wss_bearer.rb', line 397 def write_nonblock(data, exception: true) = @sock.write_nonblock(data, exception: exception) |