Network

Network Introduction

Network is the object used to check the network connection information on the mobile device. The user can check the network connection status periodically by using the properties and methods provided by the Network object.

Checking Connected Network

To check to which network the mobile device is currently connected, use the availabletype property and the watchStart and watchStop methods. The user can check the network connection information through the availabletype property periodically at a set time by executing the watchStart method. If you do not want the network connection information to be updated anymore, then execute the watchStop method.

${sample}

If you touch the Check Start button, then the currently connected network information and time information are received and displayed in the image and log. If you touch the Check Stop button, then the information is no longer updated.

Screenshot_20180718-181415

${sample_element}

Network > availabletype

This is the read-only property with information about the network to which the mobile device is currently connected. Network information according to the status value is as follows.

Value

Description

0

No network connected

1

3G or LTE network

2

WIFI network

Network > watchStart

This is the method that received the network status information from the mobile device at regular intervals. The receiving period can be set to a value between 200 and 86,400,000 ms. Receiving information can be checked in the availabletype and timestamp properties.

Network > watchStop

This is the method that ends the execution of the watchStart method.

${sample_step}

1

Configuring the Screen

Add the Network object. The added Network object can be checked in the Invisible Object window.

Place the Static and Button components to configure the screen appropriately as shown in the example figure.

Components and objects used to configure the screen are as follows.

Component / Object

ID

Network

Network00

GroupBox

GroupBox00

Static

stt_datanetwork

stt_wifi

stt_none

stt_logtitle

ImageViewer

img_datanetwork

img_wifinetwork

TextArea

ta_log

Button

btn_watch

2

Writing the watchStart Button Event Function

Write the onclick event of the watchStart button as follows. The argument of the watchStart method is in milliseconds.

this.Button00_onclick = function(obj:nexacro.Button,e:nexacro.ClickEventInfo)
{
	this.Network00.watchStart(1000);
};

3

Writing the watchStop Button Touch Event Function

Write the onclick event of the watchStop button as follows.

this.Button01_onclick = function(obj:nexacro.Button,e:nexacro.ClickEventInfo)
{
	this.Network00.watchStop();
};

4

Writing the Network Object Event Function

When the watchStart method is executed, network information is received at set intervals, and the received information can be obtained from the event function of the Network object.

When the watchStart method is executed normally, the onrecvsuccess event is called. In the availabletype property, network information is stored, and in the timestamp property, the time the network information was received is stored.

Since the availabletype property value is in numeric form, use the fn_getNetworkType function to change it to the character string form so that the user can recognize it.

this.Network00_onrecvsuccess = function(obj:nexacro.Network,e:nexacro.NetworkEventInfo)
{
	var strResult = this.fn_getNetworkType(this.Network00.availabletype);
	
	this.stt_network.set_text(strResult);
	this.stt_timestamp.set_text(this.Network00.timestamp);
};

This is the error event function that is called when an error occurs while executing the watchStart method.

this.Network00_onrecverror = function(obj:nexacro.Network,e:nexacro.NetworkErrorEventInfo)
{
	var strResult = "["+ e.errortype +" "+ e.statuscode +"] "+ e.errormsg;
	
	this.stt_network.set_text(strResult);
};

The fn_getNetworkType function converts the availabletype property value to the user-readable string and returns it.

this.fn_getNetworkType = function(intAvailableType)
{
	var strNetworkType;
	
	switch(intAvailableType)
	{
		case 1:
			strNetworkType = "3G/LTE";
			break;
		case 2:
			strNetworkType = "WIFI";
			break;
		case 0:
		default:
			strNetworkType = "NONE";			
	}
	
	return strNetworkType;
}

5

Checking on the Mobile Device

Touch the watchStart button and change the network of the mobile device to WIFI or 3G/LTE to check if the network information is received normally.

URL 접속 확인하기

Before accessing a specific URL in the app, you need to check that there is no problem with accessing the corresponding URL. At this time, you can easily check it by using the isReachable method of the Network object.

${sample}

Enter the URL using the virtual keyboard and press the Enter key. If there is no problem accessing the URL, then the browser at the bottom will display the web page. If access to the entered URL is not possible, an error message is displayed in a pop-up window.

Screenshot_20180718-181745

${sample_element}

Network > isReachable

This is the method that checks whether there is a problem with accessing a specific URL in the mobile app.

${sample_step}

1

Configuring the Screen

Add the Network object. The added Network object can be checked in the Invisible Object window.

Place the Static and Button components to configure the screen and the Edit component to receive the URL input appropriately as shown in the example figure.

Components and objects used to configure the screen are as follows.

Component / Object

ID

Network

Network00

Static

stt_text

Edit

edt_url

Button

btn_verification

btn_clear

2

Writing the Go Button Event Function

Write the onclick event of the Go button as follows.

this.btn_go_onclick = function(obj:nexacro.Button,e:nexacro.ClickEventInfo)
{
	var strURL = this.edt_url.value;
	
	if(nexacro._isNull(strURL) || strURL == "")
	{
		this.edt_url.setFocus();
	}
	else
	{
		this.Network00.isReachable(strURL);	
	}		
};

3

Writing the Edit Component Event Function

Write the onkeydown event function of the Edit component. Process the enter key input of the virtual keyboard.

this.edt_url_onkeydown = function(obj:nexacro.Edit,e:nexacro.KeyEventInfo)
{
	if(e.keycode == "13")	//Enter key code
	{			
		this.btn_go_onclick();
		this.btn_go.setFocus();
	}
};

4

Writing the Network Object Event Function

The onrecvsuccess event is called when the isReachable is executed normally.

this.Network00_onrecvsuccess = function(obj:nexacro.Network,e:nexacro.NetworkEventInfo)
{
	var strResult = this.edt_url.value +" is reachable.";
	
	this.stt_result.set_text(strResult);
};

This is the error event function that is called when an error occurs while executing the isReachable method.

this.Network00_onrecverror = function(obj:nexacro.Network,e:nexacro.NetworkErrorEventInfo)
{
	var strResult = this.edt_url.value +" is unreachable.";
	
	this.stt_result.set_text(strResult);
};

5

Checking on the Mobile Device

Enter the URL and touch the Go button to check whether access to the URL is possible.