Sha256: 624d1b3e8cfd7a7d240b7d1eb6519f5ee249b4b78cd295beb44eb61df4e34f56

Contents?: true

Size: 587 Bytes

Versions: 13

Compression:

Stored size: 587 Bytes

Contents

module WebSocket
  class Driver

    class Hybi
      class StreamReader
        def initialize
          @buffer = Driver.encode('', :binary)
        end

        def put(string)
          return unless string and string.bytesize > 0
          @buffer << Driver.encode(string, :binary)
        end

        def read(length)
          buffer_size = @buffer.bytesize
          return nil if length > buffer_size

          chunk   = @buffer.byteslice(0, length)
          @buffer = @buffer.byteslice(length, buffer_size - length)

          chunk
        end
      end
    end

  end
end

Version data entries

13 entries across 13 versions & 2 rubygems

Version Path
solidus_backend-1.0.0.pre3 vendor/bundle/gems/websocket-driver-0.5.4/lib/websocket/driver/hybi/stream_reader.rb
solidus_backend-1.0.0.pre2 vendor/bundle/gems/websocket-driver-0.5.4/lib/websocket/driver/hybi/stream_reader.rb
solidus_backend-1.0.0.pre vendor/bundle/gems/websocket-driver-0.5.4/lib/websocket/driver/hybi/stream_reader.rb
websocket-driver-0.5.4-java lib/websocket/driver/hybi/stream_reader.rb
websocket-driver-0.5.4 lib/websocket/driver/hybi/stream_reader.rb
websocket-driver-0.5.3-java lib/websocket/driver/hybi/stream_reader.rb
websocket-driver-0.5.3 lib/websocket/driver/hybi/stream_reader.rb
websocket-driver-0.5.2-java lib/websocket/driver/hybi/stream_reader.rb
websocket-driver-0.5.2 lib/websocket/driver/hybi/stream_reader.rb
websocket-driver-0.5.1-java lib/websocket/driver/hybi/stream_reader.rb
websocket-driver-0.5.1 lib/websocket/driver/hybi/stream_reader.rb
websocket-driver-0.5.0 lib/websocket/driver/hybi/stream_reader.rb
websocket-driver-0.5.0-java lib/websocket/driver/hybi/stream_reader.rb