Class: Opensips::MI::Transport::Fifo

Inherits:
Abstract
  • Object
show all
Defined in:
lib/opensips/mi/transport/fifo.rb

Overview

FIFO transport to communicate with MI

Instance Method Summary collapse

Methods inherited from Abstract

#adapter_request, #adapter_response

Constructor Details

#initialize(args) ⇒ Fifo

Returns a new instance of Fifo.



14
15
16
17
18
19
20
21
# File 'lib/opensips/mi/transport/fifo.rb', line 14

def initialize(args)
  super()
  raise_invalid_params unless args.is_a?(Hash)
  @fifo_name, @reply_dir, @timeout = args.values_at(:fifo_name, :reply_dir, :timeout)
  raise_invalid_params if @fifo_name.nil?
  @reply_dir ||= "/tmp"
  @timeout ||= 5
end

Instance Method Details

#send(rpc) ⇒ Object



23
24
25
26
27
28
29
# File 'lib/opensips/mi/transport/fifo.rb', line 23

def send(rpc)
  reply_file = create_reply_file
  write(reply_file, rpc)
  read(reply_file)
ensure
  reply_file.unlink if reply_file&.exist?
end