1414 limitations under the License.
1515 */
1616
17- // this must be used when executing directly from source code downloaded from git repo
18- //let wmclient = require('./src/app/wmclient')
17+ // Use the commented require to refer local source code instead of client installed from NPM repo
18+ // let wmclient = require('./src/app/wmclient')
1919let wmclient = require ( 'wmclient' )
2020const http = require ( "http" )
2121const TEXT_SEPARATOR = '---------------------------------------------------------------------------------'
@@ -36,6 +36,7 @@ const example = async () => {
3636 console . log ( 'Static capabilities loaded: ' + client . staticCaps . length )
3737 console . log ( 'Virtual capabilities loaded: ' + client . virtualCaps . length + '\n' )
3838 separate ( )
39+ // Get server info
3940 try {
4041 let info = await client . getInfo ( )
4142 console . log ( 'Server info: \n' )
@@ -46,7 +47,7 @@ const example = async () => {
4647 console . log ( "Unable to load WURFL Info" )
4748 }
4849 separate ( )
49- // Perform a detection using passing a whole HTTP request to WM server API
50+ // Perform a detection using a whole HTTP request to WM server API
5051 // When building a request object for node, headers must be lowercase, according to Node standard
5152 let req_headers = {
5253 'accept' : 'text/html, application/xml;q=0.9, application/xhtml+xml, image/png, image/webp, image/jpeg, image/gif, image/x-xbitmap, */*;q=0.1' ,
@@ -64,6 +65,7 @@ const example = async () => {
6465 'x-operamini-phone-Ua' : 'Mozilla/5.0 (Linux; Android 8.1.0; SM-J610G Build/M1AJQ; wv) AppleWebKit/537.36 (KHTML, like Gecko) Version/4.0 Chrome/69.0.3497.100 Mobile Safari/537.36' ,
6566 }
6667
68+ // Request refer a local WM server. Change the host and port to your WM server if needed
6769 let options = {
6870 protocol : 'http:' ,
6971 host : 'localhost' ,
@@ -75,6 +77,8 @@ const example = async () => {
7577 let req = http . request ( options )
7678 req . headers = req_headers
7779 req . end ( )
80+
81+ // Get device info using wmclient
7882 let device
7983 try {
8084 device = await client . lookupRequest ( req )
@@ -96,7 +100,9 @@ const example = async () => {
96100 }
97101 }
98102 separate ( )
99- // Get all the device manufacturers, and print the first twenty
103+ // Get some data using wmclient
104+
105+ // Get all the device manufacturers, and print the first twenty returned
100106 let deviceMakes = await client . getAllDeviceMakes ( )
101107 let limit = 20
102108 console . log ( "Print the first " + limit + " Brand of " + deviceMakes . length )
@@ -106,7 +112,7 @@ const example = async () => {
106112 console . log ( " - " + deviceMakes [ i ] )
107113 }
108114 separate ( )
109- // Now call the WM server to get all device model and marketing names produced by Apple
115+ // Get all device model and marketing names produced by Apple
110116 let brandName = "Apple"
111117 try {
112118 let devsForMake = await client . getAllDevicesForMake ( brandName )
@@ -124,7 +130,7 @@ const example = async () => {
124130 console . log ( `Error looking for models for device, brand ${ error . message } ` )
125131 }
126132 separate ( )
127- // Now call the WM server to get all operative system names
133+ // Get all operative system names
128134 let oses = await client . getAllOSes ( )
129135 // Sort and print all OS names
130136 console . log ( "Print the list of OSes" )
@@ -133,7 +139,7 @@ const example = async () => {
133139 console . log ( " - " + oses [ i ] )
134140 }
135141
136- // Let's call the WM server to get all version of the Android OS
142+ // Get all Android OS versions
137143 let os = 'Android'
138144 try {
139145 let versions = await client . getAllVersionsForOS ( os )
0 commit comments