Class: Sip2::Connection
- Inherits:
-
Object
- Object
- Sip2::Connection
- Defined in:
- lib/sip2/connection.rb
Overview
Sip2 Connection
Constant Summary collapse
- LINE_SEPARATOR =
"\r"
Instance Method Summary collapse
-
#initialize(socket:, ignore_error_detection: false) ⇒ Connection
constructor
A new instance of Connection.
- #method_missing(method_name, *args, **kwargs) ⇒ Object
- #respond_to_missing?(method_name, _include_private = false) ⇒ Boolean
- #send_message(message) ⇒ Object
Constructor Details
#initialize(socket:, ignore_error_detection: false) ⇒ Connection
Returns a new instance of Connection.
10 11 12 13 14 |
# File 'lib/sip2/connection.rb', line 10 def initialize(socket:, ignore_error_detection: false) @socket = socket @ignore_error_detection = ignore_error_detection @sequence = 1 end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
Instance Method Details
#respond_to_missing?(method_name, _include_private = false) ⇒ Boolean
37 38 39 |
# File 'lib/sip2/connection.rb', line 37 def respond_to_missing?(method_name, _include_private = false) !Messages::Base.(method_name).nil? || super end |
#send_message(message) ⇒ Object
16 17 18 19 20 21 22 23 24 25 26 |
# File 'lib/sip2/connection.rb', line 16 def () = with_checksum with_error_detection write_with_timeout # Read the response and strip any leading newline # - Some ACS terminate messages with /r/n by mistake. # We need to remove from the front (i.e. buffer remnant from the previous message) response = read_with_timeout&.[](/\A\n?(.*)\z/, 1) response if sequence_and_checksum_valid? response ensure @sequence += 1 end |