Skip to content

Web Library

Uri


Description

Represents a Uniform Resource Identifier (URI), in the form of an Object

Properties

Name Data Type Static Readonly Description
Authority string No No Represents the Hostname/IP Address and the port number of a server
Host string No No Represents the Hostname or IP Address of a server (port number not included)
Port int No No Represents the port number of the URI. If not specified, the port number gets its value from the protocol. If the protocol is unknown or does not have a default port number, the property is -1
Scheme string No No Represents the scheme used in the URI.

Methods

CreateFromString(string)

Description

Parse a URL and get a new URI object

Return Type : WebLib.Uri

Static : Yes

Namespace : WebLib.Uri

Parameters

Name Data Type Description
StringToConvert string A URL to get it Uri object representation

Syntax

WebLib.Uri uri = WebLib.Uri.CreateFromString("https://google.com");



Request


Description

Enables Mamba to read the HTTP values sent by a client during a Web Request

Properties

Name Data Type Static Readonly Description
ApplicationPath string No No Application's virtual application root path on the server.

Methods

GetServerVariable(string)

Description

Get value from a server variable.

Return Type : Object

Static : Yes

Namespace : WebLib.Request

Parameters

Name Data Type Description
Key string Name of the variable.

Syntax

WebLib.Request.GetServerVariable("HTTP_HOST");



RedirectToUrl(string)

Description

Redirect to URL

Return Type :

Static : Yes

Namespace : WebLib.Request

Parameters

Name Data Type Description
Url string The target URL.

Syntax

WebLib.Request.RedirectToUrl("https://google.com");



RedirectToUrl(string, string)

Description

Redirect to URL and specify the target window of the new page

Return Type :

Static : Yes

Namespace : WebLib.Request

Parameters

Name Data Type Description
Url string The target URL.
Target string Where the new site will be loaded.

Syntax

WebLib.Request.RedirectToUrl("https://google.com", "_self");



IsAuthenticated()

Description

Check whether the Web Request comes from an Authenticated User or not.

Return Type : bool

Static : Yes

Namespace : WebLib.Request

Syntax

bool isAuthenticated = WebLib.Request.IsAuthenticated();



GetUrl()

Description

Get the Application URL of the Web Request

Return Type : WebLib.Uri

Static : Yes

Namespace : WebLib.Request

Syntax

WebLib.Uri siteURL = WebLib.Request.GetUrl();



GetClientIp()

Description

Get the IP Address of the Client sending the Web Request

Return Type : string

Static : Yes

Namespace : WebLib.Request

Syntax

var ip = WebLib.Request.GetClientIp();



GetQueryStringParameter(string)

Description

Retrieve the value of a specific URL Parameter

Return Type : string

Static : Yes

Namespace : WebLib.Request

Parameters

Name Data Type Description
Key string A key on query parameter dictionary.

Syntax

string queryStringParameterValue = WebLib.Request.GetQueryStringParameter("_currentControllerAction");



GetHeader(string)

Description

Retrieve the value of a specific HTTP Header entry

Return Type : string

Static : Yes

Namespace : WebLib.Request

Parameters

Name Data Type Description
Key string The name of an entry, inside the Header of the HTTP Request

Syntax

string headerValue = WebLib.Request.GetHeader("Accept-Language")



SocketClient


Description

Implements a Berkeley Socket Client

Properties

Name Data Type Static Readonly Description
IsConnected bool No No Gets a value indicating whether the Socket Client is connected to its remote host

Methods

CreateConnection(string, string, int)

Description

Establishes a connection to a remote host. The host is specified by an IP address and a port number.

Return Type : WebLib.SocketClient

Static : Yes

Namespace : WebLib.SocketClient

Parameters

Name Data Type Description
name string An identifier for the connection.
ip string IP Address of the destination server.
port int Port of the destination server.

Syntax

WebLib.SocketClient conn = WebLib.SocketClient.CreateConnection("conn1", "127.0.0.1", "7000");



GetConnection(string)

Description

Retrieve an already established connection with the provided identifier.

Return Type : WebLib.SocketClient

Static : Yes

Namespace : WebLib.SocketClient

Parameters

Name Data Type Description
name string An identifier for the connection.

Syntax

WebLib.SocketClient conn = WebLib.SocketClient.GetConnection("conn1");



CloseConnection(string)

Description

Close an already established connection with the provided identifier.

Return Type : void

Static : Yes

Namespace : WebLib.SocketClient

Parameters

Name Data Type Description
name string An identifier for the connection.

Syntax

WebLib.SocketClient.CloseConnection("conn1");



StartReceiving(Func[Array[byte], bool])

Description

Start receiving messages from the destination host.

Return Type : void

Static : No

Namespace : WebLib.SocketClient

Parameters

Name Data Type Description
onReceive Func On receive function handler

Syntax

conn.StartReceiving(msg => {
    Domain.MyReceivedMessage.Insert(msg);
    return true;    
});



StartReceiving(Func[Array[byte], bool], Array[byte])

Description

Start receiving messages from the destination host, using a pre-defined Delimited to identify incoming message parts

Return Type : void

Static : No

Namespace : WebLib.SocketClient

Parameters

Name Data Type Description
onReceive Func On receive function handler.
msgDelimeter Array Delimeter as array of bytes

Syntax

conn.StartReceiving((Array[byte] msg) => {
    // Do something with the msg
    return true;    
}, CommonLib.Utilities.UTF8ToByteArray("|"));



StartReceiving(Func[Array[byte], bool], string)

Description

Start receiving message from the destination host and act upon them with the specified onReceive logic

Return Type : void

Static : No

Namespace : WebLib.SocketClient

Parameters

Name Data Type Description
onReceive Func On receive function handler.
msgDelimeter string Delimeter as string.

Syntax

conn.StartReceiving((Array[byte] msg) => {
    // Do something with the msg
    return true;    
}, "|");



Send(string)

Description

Sends data (represented in a string) to a connected Socket.

Return Type : void

Static : No

Namespace : WebLib.SocketClient

Parameters

Name Data Type Description
data string A string that contains the data to be sent.

Syntax

WebLib.SocketClient.GetConnection("conn1").Send("Hi, there! How do you like zAppDev so far?");



Send(Array[byte])

Description

Sends data (represented in an array of bytes) to a connected Socket.

Return Type : void

Static : No

Namespace : WebLib.SocketClient

Parameters

Name Data Type Description
data Array An array of Bytes that contains the data to be sent.

Syntax

WebLib.SocketClient.GetConnection("conn1").Send(CommonLib.Utilities.UTF8ToByteArray("This was sent with zAppDev!"));