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

Summary

Actions Summary Table

ActionsDescription
AddListener(Libraries.Network.NetworkRequestListener listener)This action adds a NetworkRequestListener to the connection which will be notified when the response returns.
Compare(Libraries.Language.Object object)This action compares two object hash codes and returns an integer.
Equals(Libraries.Language.Object object)This action determines if two objects are equal based on their hash code values.
GetHashCode()This action gets the hash code for an object.
GetListenerIterator()This action returns a list of NetworkRequestListeners attached to the connection.
GetNetworkRequest()This action sends a network request over the connection in the object.
GetNewResponseEvent()This action returns a new NetworkResponseEvent.
GetServerNameIdentification()This action retrieves the value of the ServerNameIdentification (SNI) check for Quorum using the desktop.
Notify(Libraries.Network.NetworkResponseEvent response)This action notifies the listeners with the response event.
RemoveListener(Libraries.Network.NetworkRequestListener listener)This action adds a NetworkRequestListener to the connection which will be notified when the response returns.
SendRequest(Libraries.Network.NetworkRequest request)This action sends a Network request over the connection in the object.
SetResponse(Libraries.Network.NetworkResponseEvent response)This action sets a response event in the connection object and notifies the listeners.
SetServerNameIdentification(boolean value)This action enables or disables the ServerNameIdentification (SNI) extension in Java for Quorum using the desktop.

Actions Documentation

AddListener(Libraries.Network.NetworkRequestListener listener)

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

Example Code

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

Parameters

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.

Example Code

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

Parameters

Return

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

Equals(Libraries.Language.Object object)

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

Example Code

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

Parameters

Return

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

GetHashCode()

This action gets the hash code for an object.

Example Code

Object o
        integer hash = o:GetHashCode()

Return

integer: The integer hash code of the object.

GetListenerIterator()

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

Example Code

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

Return

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

GetNetworkRequest()

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

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

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

Return

Libraries.Network.NetworkRequest: The NetworkRequest.

GetNewResponseEvent()

This action returns a new NetworkResponseEvent.

Example Code

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

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

Return

Libraries.Network.NetworkResponseEvent: The NetworkResponseEvent.

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.

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

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

Return

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

Notify(Libraries.Network.NetworkResponseEvent response)

This action notifies the listeners with the response event.

Example Code

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

Parameters

RemoveListener(Libraries.Network.NetworkRequestListener listener)

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

Example Code

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

Parameters

SendRequest(Libraries.Network.NetworkRequest request)

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

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

Parameters

SetResponse(Libraries.Network.NetworkResponseEvent response)

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

Example Code

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

Parameters

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.

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

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

Parameters