lib/freewifi.rb in freewifi-0.1.8 vs lib/freewifi.rb in freewifi-0.1.9

- old
+ new

@@ -266,22 +266,23 @@ end class PortalFwifi_1 - attr_accessor :apigw_wsdl, - :apigw_endpoint, - :apigw_namespace, - :apigw_wsse_aut_log, - :apigw_wsse_aut_pass, - :general_procedures, + attr_accessor :general_procedures, :mtik_control_ips_get, :mtik_user, :mtik_password, :mongo_connector_wifi_1, :remote_ip, - :real_ip + :real_ip, + :telegram_api_url, + :telegram_chat_id, + :mongo_ip, + :mongo_port, + :mongo_database, + :additional_func_wifi_1 def initialize(apigw_wsdl, apigw_endpoint, apigw_namespace, @@ -299,39 +300,69 @@ remote_ip, real_ip, hua_wlc_1_ip, hua_wlc_2_ip, hua_wlc_login, - hua_wlc_password + hua_wlc_password, + telegram_api_url, + telegram_chat_id ) - @apigw_wsdl = apigw_wsdl - @apigw_endpoint = apigw_endpoint - @apigw_namespace = apigw_namespace - @apigw_wsse_aut_log = apigw_wsse_aut_log - @apigw_wsse_aut_pass = apigw_wsse_aut_pass - @general_procedures = WiFiPortal_1.new(apigw_wsdl, apigw_endpoint, apigw_namespace, apigw_wsse_aut_log, apigw_wsse_aut_pass, iwag1_host, iwag_username, iwag_password, mtik_control_ips_get, mtik_user, mtik_password, hua_wlc_1_ip, hua_wlc_2_ip, hua_wlc_login, hua_wlc_password) + @general_procedures = WiFiPortal_1.new(apigw_wsdl, + apigw_endpoint, + apigw_namespace, + apigw_wsse_aut_log, + apigw_wsse_aut_pass, + iwag1_host, + iwag_username, + iwag_password, + mtik_control_ips_get, + mtik_user, + mtik_password, + hua_wlc_1_ip, + hua_wlc_2_ip, + hua_wlc_login, + hua_wlc_password + ) @mtik_control_ips_get = mtik_control_ips_get @mtik_user = mtik_user @mtik_password = mtik_password - @mongo_connector_wifi_1 = MongoWifiCl_1.new(mongo_ip, mongo_port, mongo_database) @remote_ip = remote_ip @real_ip = real_ip + @additional_func_wifi_1 = InternalFunc_1.new + @telegram_api_url = telegram_api_url + @telegram_chat_id = telegram_chat_id + @mongo_ip = mongo_ip + @mongo_port = mongo_port + @mongo_database = mongo_database end def wifi_get_subs_info_return_1(ipaddress) input_params = {:ipaddress => ipaddress} output_params = {} - begin - resp_procedure = general_procedures.get_subs_info_return_1(ipaddress) - output_params = resp_procedure - rescue - output_params = {:code => 507, :result => "Unknown SDK error"} + subs_info_ret_1_thr1 = Thread.new do + begin + resp_procedure = general_procedures.get_subs_info_return_1(ipaddress) + output_params = resp_procedure + rescue + output_params = {:code => 507, :result => "Unknown SDK error"} + end end + subs_info_ret_1_thr1.join - mongo_connector_wifi_1.audit_logger_wifi_portal_1("wifi_get_subs_info_return_1", remote_ip, input_params, output_params, real_ip) + subs_info_ret_1_thr2 = Thread.new do + begin + mongo_connector_wifi_1 = MongoWifiCl_1.new(mongo_ip, mongo_port, mongo_database) + mongo_connector_wifi_1.audit_logger_wifi_portal_1("wifi_get_subs_info_return_1", remote_ip, input_params, output_params, real_ip) + rescue + additional_func_wifi_1.printer_texter_wifi_1({:input_params => input_params, :output_params => {:result => "mongo failed"}, :procedure => "wifi_get_subs_info_return_1", :file => "freewifi.rb"}, "debug") + additional_func_wifi_1.telegram_message_1("{:function => \"wifi_get_subs_info_return_1\", :result => \"failed communicate with mongo database\", :sdk => \"freewifi\"}", telegram_api_url, telegram_chat_id) + end + end + subs_info_ret_1_thr2.join + output_params end end