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
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
RedirectToUrl(string)¶
Description
Redirect to URL
Return Type :
Static : Yes
Namespace : WebLib.Request
Parameters
| Name | Data Type | Description |
|---|---|---|
| Url | string | The target URL. |
Syntax
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
IsAuthenticated()¶
Description
Check whether the Web Request comes from an Authenticated User or not.
Return Type : bool
Static : Yes
Namespace : WebLib.Request
Syntax
GetUrl()¶
Description
Get the Application URL of the Web Request
Return Type : WebLib.Uri
Static : Yes
Namespace : WebLib.Request
Syntax
GetClientIp()¶
Description
Get the IP Address of the Client sending the Web Request
Return Type : string
Static : Yes
Namespace : WebLib.Request
Syntax
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
HasCookie(string)¶
Description
Returns true if Request contains the cookie with the given name
Return Type : bool
Static : Yes
Namespace : WebLib.Request
Parameters
| Name | Data Type | Description |
|---|---|---|
| CookieName | string | The name of the cookie |
Syntax
GetCookieValue(string)¶
Description
Returns the Cookie's value
Return Type : string
Static : Yes
Namespace : WebLib.Request
Parameters
| Name | Data Type | Description |
|---|---|---|
| CookieName | string | The name of the cookie |
Syntax
CreateCookie(string, string, DateTime)¶
Description
Add a cookie and send to HTTP Response
Return Type : void
Static : Yes
Namespace : WebLib.Request
Parameters
| Name | Data Type | Description |
|---|---|---|
| CookieName | string | The name of the cookie |
| CookieValue | string | The name of the cookie |
| Expiration | DateTime | Expiration Date |
Syntax
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
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
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
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
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
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
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!"));