zh Kooboo Logo Documents

NET

 

Providing methods for Network operations.
 

URL

A wrapped HTTP client capable of performing GET, POST, DELETE, and other HTTP requests.

Intelligent suggestions are provided for each method. The existing methods are as follows:

 
k.net.url.delete
k.net.url.deleteAsObject
k.net.url.downloadZip
k.net.url.get
k.net.url.getAsBinary
k.net.url.getAsObject
k.net.url.getJson
k.net.url.patch
k.net.url.patchAsObject
k.net.url.patchData
k.net.url.post
k.net.url.postAsBinary
k.net.url.postAsObject
k.net.url.postData
k.net.url.postform
k.net.url.put
k.net.url.putAsObject
 
A supremely straightforward method for utilizing GET can be implemented as follows:
 
var result = k.net.url.get("https://www.kooboo.com");
k.response.write(result);
 
webSocket
 
Convenient creation and utilization of Web Sockets
 
accept
const ids= k.net.webSocket.accept('user_1',ctx=>{ 
// ctx.text 
// ctx.binary 
});
 
send
 
const connection= k.webSocket.get('user_1'); 
connection.sendText('hello',()=>{ 
// after send message 
});
 
IP
 
Retrieving the current server configuration's IP,  requires the support of an IP database to query the country and region associated with the IP address. This feature is exclusively available in the Kooboo Online Edition.
 
var myip = k.net.IP.myIP;

var city = k.net.IP.getCity("112.5.171.220");
if (city) {
    k.response.write(city.countryCode);
}