Class: Envoy::Server::Channel

Inherits:
Object
  • Object
show all
Defined in:
lib/envoy/server/channel.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(trunk, web, header) ⇒ Channel

Returns a new instance of Channel.



9
10
11
12
13
14
15
# File 'lib/envoy/server/channel.rb', line 9

def initialize trunk, web, header
  @trunk = trunk
  @web = web
  @trunk.channels[id] = self
  @trunk.send_object :connection, id
  stream header
end

Instance Attribute Details

#trunkObject

Returns the value of attribute trunk.



7
8
9
# File 'lib/envoy/server/channel.rb', line 7

def trunk
  @trunk
end

#webObject

Returns the value of attribute web.



7
8
9
# File 'lib/envoy/server/channel.rb', line 7

def web
  @web
end

Instance Method Details

#idObject



25
26
27
# File 'lib/envoy/server/channel.rb', line 25

def id
  @id ||= SecureRandom.hex(4)
end

#message(data) ⇒ Object



21
22
23
# File 'lib/envoy/server/channel.rb', line 21

def message data
  @trunk.send_object :message, data
end

#stream(data) ⇒ Object



17
18
19
# File 'lib/envoy/server/channel.rb', line 17

def stream data
  @trunk.send_object :stream, id, data
end