Class: Net::TTI::ProtocolNegotiationResponse

Inherits:
Message
  • Object
show all
Defined in:
lib/net/tti/messages/protocol_negotiation_response.rb

Constant Summary

Constants inherited from Message

Message::TTC_CODE_DATA_TYPE_NEGOTIATION, Message::TTC_CODE_ERROR, Message::TTC_CODE_FUNCTION_CALL, Message::TTC_CODE_OK, Message::TTC_CODE_PROTOCOL_NEGOTIATION

Instance Method Summary collapse

Methods inherited from Message

from_data_string, handles_response_for_ttc_code

Instance Method Details

#populate_connection_parameters(conn_params) ⇒ Object



24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
# File 'lib/net/tti/messages/protocol_negotiation_response.rb', line 24

def populate_connection_parameters( conn_params )
  conn_params.ttc_version = self.ttc_version
  conn_params.ttc_server = self.ttc_server
  conn_params.character_set = self.character_set
  conn_params.server_flags = self.server_flags
  conn_params.server_compiletime_capabilities = Capabilities.from_binary_string( server_compiletime_capabilities )
  conn_params.server_runtime_capabilities = Capabilities.from_binary_string( server_runtime_capabilities )

  ttc_server_map = {
    # (start of) protocol handler string => {params}
    "IBMPC/WIN_NT-" => {:architecture => :x86, :platform => :windows},
    "IBMPC/WIN_NT64" => {:architecture => :x64, :platform => :windows},
    "Linuxi386/Linux" => {:architecture => :x86, :platform => :linux},
    "x86_64/Linux" => {:architecture => :x64, :platform => :linux},
    "Sun386i/SunOS" => {:architecture => :x86, :platform => :solaris},
    "AMD64/SunOS" => {:architecture => :x64, :platform => :solaris},
  }

  ph_match, match_params = ttc_server_map.find do |ph_start, params|
    ttc_server.start_with?(ph_start)
  end

  if ph_match
    conn_params.architecture = match_params[:architecture]
    conn_params.platform = match_params[:platform]
  else
    raise Net::TTI::Exceptions::UnsupportedPlatform.new( ttc_server )
  end
end