Libraries.Network.NetworkRequestListener Documentation

This is a blueprint class to specify the call back function from the network request.

Example Code



use Libraries.Network.NetworkConnection
use Libraries.Network.NetworkRequest
use Libraries.Network.NetworkResponseEvent
use Libraries.Network.NetworkRequestListener

class Main is NetworkRequestListener
action Main
    NetworkRequest request
    request:SetRequestTypeToGet()
    request:SetWebAddress("https://quorumlanguage.com/GETtest.php")
    NetworkConnection http
    http:AddListener(me)
    http:SendRequest(request)
end

action ResponseReceived(NetworkResponseEvent response)
    output response:GetResponseText()
end
end

Inherits from: Libraries.Language.Object

Actions Documentation

Compare(Libraries.Language.Object object)

This action compares two object hash codes and returns an integer. The result is larger if this hash code is larger than the object passed as a parameter, smaller, or equal. In this case, -1 means smaller, 0 means equal, and 1 means larger. This action was changed in Quorum 7 to return an integer, instead of a CompareResult object, because the previous implementation was causing efficiency issues.

Parameters

Return

integer: The Compare result, Smaller, Equal, or Larger.

Example

Object o
Object t
integer result = o:Compare(t) //1 (larger), 0 (equal), or -1 (smaller)

DownloadProgress(integer length, integer read)

This action allows us to obtain the progress of any file download as the network is processing it.

Parameters

  • integer length: The amount of data the server claims it is sending
  • integer read: the amount of data that has been processed so far

Example



use Libraries.Network.NetworkConnection
use Libraries.Network.NetworkRequest
use Libraries.Network.NetworkResponseEvent
use Libraries.Network.NetworkRequestListener

class Main is NetworkRequestListener
    action Main
        NetworkConnection conn
        conn:AddListener(me)
        File myFile
        myFile:SetPath("logo.png")
        NetworkRequest request
        request:SetRequestTypeToGet()
        request:SetWebAddress("https://quorumlanguage.com/media/QuorumLogo.png")
        request:SetDownloadFile(myFile)
    end

    action ResponseReceived(NetworkResponseEvent response)
        output response:GetResponseText()
    end

    action DownloadProgress(integer length, integer read)
        output read + " of " + length + " bytes read." 
    end
end

Equals(Libraries.Language.Object object)

This action determines if two objects are equal based on their hash code values.

Parameters

Return

boolean: True if the hash codes are equal and false if they are not equal.

Example

use Libraries.Language.Object
use Libraries.Language.Types.Text
Object o
Text t
boolean result = o:Equals(t)

GetHashCode()

This action gets the hash code for an object.

Return

integer: The integer hash code of the object.

Example

Object o
integer hash = o:GetHashCode()

ResponseReceived(Libraries.Network.NetworkResponseEvent response)

This is a blueprint method to specify the call back function from the network request.

Parameters

Example



use Libraries.Network.NetworkConnection
use Libraries.Network.NetworkRequest
use Libraries.Network.NetworkResponseEvent
use Libraries.Network.NetworkRequestListener

class Main is NetworkRequestListener
    action Main
        NetworkRequest request
        request:SetRequestTypeToGet()
        request:SetWebAddress("https://quorumlanguage.com/GETtest.php")
        NetworkConnection http
        http:AddListener(me)
        http:SendRequest(request)
    end

    action ResponseReceived(NetworkResponseEvent response)
        output response:GetResponseText()
    end
end