Libraries.Network.NetworkConnection Documentation

This class is used to manage a connection to a server using the internet protocol. More information on the internet protocol, called Hyper Text Transfer Protocol (HTTP) can be found at: https://www.w3.org/Protocols/.

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

AddListener(Libraries.Network.NetworkRequestListener listener)

This action adds a NetworkRequestListener to the connection which will be notified when the response returns.

Parameters

Example



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

class Main is NetworkRequestListener
    action Main
        NetworkConnection http
        http:AddListener(me)
    end

    action ResponseReceived(NetworkResponseEvent response)
        // do something with the response
    end
end

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)

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()

GetListenerIterator()

This action returns a list of NetworkRequestListeners attached to the connection.

Return

Libraries.Containers.Iterator: An iterator to the list of NetworkRequestListeners.

Example



use Libraries.Network.NetworkConnection
use Libraries.Network.NetworkRequestListener
use Libraries.Network.NetworkResponseEvent
use Libraries.Containers.Iterator

class Main is NetworkRequestListener
    action Main
        NetworkConnection http
        http:AddListener(me)
        Iterator<NetworkRequestListener> list = http:GetListenerIterator()
    end

    action ResponseReceived(NetworkResponseEvent response)
        // do something with the response
    end
end

GetNetworkRequest()

This action sends a network request over the connection in the object.

Return

Libraries.Network.NetworkRequest: The NetworkRequest.

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)
        NetworkRequest copy
        copy = http:GetNetworkRequest()
    end

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

GetNewResponseEvent()

This action returns a new NetworkResponseEvent.

Return

Libraries.Network.NetworkResponseEvent: The NetworkResponseEvent.

Example



use Libraries.Network.NetworkConnection
use Libraries.Network.NetworkResponseEvent

class Main
    action Main
        NetworkConnection http
        NetworkResponseEvent response = http:GetNewResponseEvent()
    end
end

GetServerNameIdentification()

This action retrieves the value of the ServerNameIdentification (SNI) check for Quorum using the desktop. The default value is true. See the SetServerNameIdentification action for a further description.

Return

boolean: value The value of the SNI setting for the connection.

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
        output http:GetServerNameIdentification()
        http:AddListener(me)
        http:SendRequest(request)
        NetworkRequest copy
        copy = http:GetNetworkRequest()
    end

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

Notify(integer length, integer read)

This action notifies the listeners with the amount of data that has been processed toward a download.

Parameters

  • integer length: the total size of the download in bytes
  • integer read: the total amount of data that has been read so far in bytes

Example



use Libraries.Network.NetworkConnection
use Libraries.Network.NetworkRequestListener
use Libraries.Network.NetworkResponseEvent
use Libraries.Containers.Iterator

class Main is NetworkRequestListener
    action Main
        NetworkConnection http
        http:AddListener(me)
        http:Notify(0,1)
    end

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

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

Notify(Libraries.Network.NetworkResponseEvent response)

This action notifies the listeners with the response event.

Parameters

Example



use Libraries.Network.NetworkConnection
use Libraries.Network.NetworkRequestListener
use Libraries.Network.NetworkResponseEvent
use Libraries.Containers.Iterator

class Main is NetworkRequestListener
    action Main
        NetworkConnection http
        http:AddListener(me)
        NetworkResponseEvent response = http:GetNewResponseEvent()
        response:SetResponseText("Hello world!")
        http:Notify(response)
    end

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

RemoveListener(Libraries.Network.NetworkRequestListener listener)

This action adds a NetworkRequestListener to the connection which will be notified when the response returns.

Parameters

Example



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

class Main is NetworkRequestListener
    action Main
        NetworkConnection http
        http:AddListener(me)
        http:RemoveListener(me)
    end

    action ResponseReceived(NetworkResponseEvent response)
        // do something with the response
    end
end

SendRequest(Libraries.Network.NetworkRequest request)

This action sends a Network request over the connection in the object.

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

SetDownloadProgress(integer length, integer read)

This action sets a response event indicating progress toward a download.

Parameters

  • integer length
  • integer read

Example



use Libraries.Network.NetworkConnection
use Libraries.Network.NetworkRequestListener
use Libraries.Network.NetworkResponseEvent
use Libraries.Containers.Iterator

class Main is NetworkRequestListener
    action Main
        NetworkConnection http
        http:AddListener(me)
        http:SetDownloadProgress(0,1)
    end

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

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

SetResponse(Libraries.Network.NetworkResponseEvent response)

This action sets a response event in the connection object and notifies the listeners.

Parameters

Example



use Libraries.Network.NetworkConnection
use Libraries.Network.NetworkRequestListener
use Libraries.Network.NetworkResponseEvent
use Libraries.Containers.Iterator

class Main is NetworkRequestListener
    action Main
        NetworkConnection http
        http:AddListener(me)
        NetworkResponseEvent response = http:GetNewResponseEvent()
        response:SetResponseText("Hello world!")
        http:SetResponse(response)
    end

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

SetServerNameIdentification(boolean value)

This action enables or disables the ServerNameIdentification (SNI) extension in Java for Quorum using the desktop. SNI is a security feature that checks if the name of the web server you are accessing matches the name on its authentication certificate. Normally you should keep this setting on the default (which is true), but many third party web servers are misconfigured and require a work around. If you receive an error when trying to connect such as "SSLProtocolException: handshake alert: unrecognized_name" you can set this to false and it will bypass the warning and connect anyway. Note that this only affects the java plugin on the desktop and does not affect the connection through the JavaScript plugin used by the online interactive development environment.

Parameters

  • boolean value: A boolean setting to enable or disable the SNI extension in Java.

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:SetServerNameIdentification(false)
        http:AddListener(me)
        http:SendRequest(request)
        NetworkRequest copy
        copy = http:GetNetworkRequest()
    end

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