Method: Funl::Stream#server_stream_for

Defined in:
lib/funl/stream.rb

#server_stream_for(io, type: stream_type) ⇒ Object



18
19
20
21
22
23
24
25
26
27
# File 'lib/funl/stream.rb', line 18

def server_stream_for io, type: stream_type
  ObjectStreamWrapper.new(io, type: type).tap do |stream|
    stream.consume do |h|
      raise StreamError, "bad handshake: #{h.class}" unless h.kind_of? Hash
      client_id = h["client_id"]
      stream.peer_name = "client #{client_id}"
      log.info "peer is #{stream.peer_name}"
    end
  end
end