Method: CMUX::Connection#initialize

Defined in:
lib/cmux/connection.rb

#initializeConnection

Returns a new instance of Connection.



10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
# File 'lib/cmux/connection.rb', line 10

def initialize
  buffer = FFI::Buffer.new :pointer, 1
  context = Library.cmux_create buffer

  if context.null?
    ptr = buffer.read_pointer
    begin
      error = ptr.read_string
      raise "MUX creation failed: #{error}"
    ensure
      Library.cmux_free ptr
    end
  end

  @handle = Pointer.new context
end