Class: Net::HTTP::SPDY::StreamSession

Inherits:
Object
  • Object
show all
Defined in:
lib/net/http/spdy/stream_session.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(sock) ⇒ StreamSession

Returns a new instance of StreamSession.



10
11
12
13
14
15
16
17
# File 'lib/net/http/spdy/stream_session.rb', line 10

def initialize(sock)
  @sock = sock
  @highest_id = -1
  @streams = {}
  @parser = create_parser
  @monitor = Monitor.new
  @monitor_cond = @monitor.new_cond
end

Instance Attribute Details

#monitorObject (readonly)

Returns the value of attribute monitor.



8
9
10
# File 'lib/net/http/spdy/stream_session.rb', line 8

def monitor
  @monitor
end

#monitor_condObject (readonly)

Returns the value of attribute monitor_cond.



8
9
10
# File 'lib/net/http/spdy/stream_session.rb', line 8

def monitor_cond
  @monitor_cond
end

#parserObject (readonly)

Returns the value of attribute parser.



8
9
10
# File 'lib/net/http/spdy/stream_session.rb', line 8

def parser
  @parser
end

Instance Method Details

#create(uri) ⇒ Object



19
20
21
22
23
24
# File 'lib/net/http/spdy/stream_session.rb', line 19

def create(uri)
  @monitor.synchronize do
    @highest_id += 2
  end
  return push(@highest_id, uri)
end

#known?(id) ⇒ Boolean

Returns:

  • (Boolean)


26
27
28
# File 'lib/net/http/spdy/stream_session.rb', line 26

def known?(id)
  @streams.has_key?(id)
end

#parse(buf) ⇒ Object



37
38
39
# File 'lib/net/http/spdy/stream_session.rb', line 37

def parse(buf)
  @parser << buf
end

#push(id, uri, connected = false) ⇒ Object



30
31
32
33
34
35
# File 'lib/net/http/spdy/stream_session.rb', line 30

def push(id, uri, connected=false)
  s = Stream.new(id, self, @sock, uri)
  s.connected = connected
  @streams[id] = s
  return @streams[id]
end

#streamsObject



41
42
43
# File 'lib/net/http/spdy/stream_session.rb', line 41

def streams
  @streams.values
end