Class SocketClient.Builder<B extends SocketClient.Builder<B>>
- Type Parameters:
B- the type of the Builder that is returned
- All Implemented Interfaces:
BuilderInterface
- Enclosing class:
SocketClient
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionbuild()Finish building theSocketClientobject.onEvent(SocketClient.EventCallback handler) Emitted whenclient'sactivity onconnectablechanges state.setEnableProxy(boolean enableProxy) Enable proxy support.setFamily(SocketFamily family) The address family to use for socket construction.setLocalAddress(SocketAddress localAddress) The local address constructed sockets will be bound to.setProtocol(SocketProtocol protocol) The protocol to use for socket construction, or0for default.setProxyResolver(ProxyResolver proxyResolver) The proxy resolver to usesetTimeout(int timeout) The I/O timeout for sockets, in seconds, or0for none.setTls(boolean tls) Whether to create TLS connections.setTlsValidationFlags(Set<TlsCertificateFlags> tlsValidationFlags) Deprecated.Do not attempt to ignore validation errors.setTlsValidationFlags(TlsCertificateFlags... tlsValidationFlags) Deprecated.Do not attempt to ignore validation errors.setType(SocketType type) The type to use for socket construction.Methods inherited from class org.gnome.gobject.GObject.Builder
onNotifyMethods inherited from class org.javagi.gobject.Builder
addBuilderProperty, connect, connect, connectSignals, getArena, getNames, getValues
-
Constructor Details
-
Builder
protected Builder()Default constructor for aBuilderobject.
-
-
Method Details
-
build
Finish building theSocketClientobject. This will callGObject.withProperties(org.gnome.glib.Type, java.lang.String[], org.gnome.gobject.Value[])to create a new GObject instance, which is then cast toSocketClient.- Overrides:
buildin classGObject.Builder<B extends SocketClient.Builder<B>>- Returns:
- a new instance of
SocketClientwith the properties that were set in the Builder object.
-
setEnableProxy
Enable proxy support.- Parameters:
enableProxy- the value for theenable-proxyproperty- Returns:
- the
Builderinstance is returned, to allow method chaining - Since:
- 2.22
-
setFamily
The address family to use for socket construction.- Parameters:
family- the value for thefamilyproperty- Returns:
- the
Builderinstance is returned, to allow method chaining - Since:
- 2.22
-
setLocalAddress
The local address constructed sockets will be bound to.- Parameters:
localAddress- the value for thelocal-addressproperty- Returns:
- the
Builderinstance is returned, to allow method chaining - Since:
- 2.22
-
setProtocol
The protocol to use for socket construction, or0for default.- Parameters:
protocol- the value for theprotocolproperty- Returns:
- the
Builderinstance is returned, to allow method chaining - Since:
- 2.22
-
setProxyResolver
The proxy resolver to use- Parameters:
proxyResolver- the value for theproxy-resolverproperty- Returns:
- the
Builderinstance is returned, to allow method chaining - Since:
- 2.36
-
setTimeout
The I/O timeout for sockets, in seconds, or0for none.- Parameters:
timeout- the value for thetimeoutproperty- Returns:
- the
Builderinstance is returned, to allow method chaining - Since:
- 2.22
-
setTls
Whether to create TLS connections.- Parameters:
tls- the value for thetlsproperty- Returns:
- the
Builderinstance is returned, to allow method chaining - Since:
- 2.22
-
setTlsValidationFlags
Deprecated.Do not attempt to ignore validation errors.The TLS validation flags used when creating TLS connections. The default value isTlsCertificateFlags.VALIDATE_ALL.GLib guarantees that if certificate verification fails, at least one flag will be set, but it does not guarantee that all possible flags will be set. Accordingly, you may not safely decide to ignore any particular type of error. For example, it would be incorrect to mask
TlsCertificateFlags.EXPIREDif you want to allow expired certificates, because this could potentially be the only error flag set even if other problems exist with the certificate. Therefore, there is no safe way to use this property. This is not a horrible problem, though, because you should not be attempting to ignore validation errors anyway. If you really must ignore TLS certificate errors, connect to theGSocketClient::event signal, wait for it to be emitted withSocketClientEvent.TLS_HANDSHAKING, and use that to connect toGTlsConnection::accept-certificate.- Parameters:
tlsValidationFlags- the value for thetls-validation-flagsproperty- Returns:
- the
Builderinstance is returned, to allow method chaining
-
setType
The type to use for socket construction.- Parameters:
type- the value for thetypeproperty- Returns:
- the
Builderinstance is returned, to allow method chaining - Since:
- 2.22
-
setTlsValidationFlags
Deprecated.Do not attempt to ignore validation errors.The TLS validation flags used when creating TLS connections. The default value isTlsCertificateFlags.VALIDATE_ALL.GLib guarantees that if certificate verification fails, at least one flag will be set, but it does not guarantee that all possible flags will be set. Accordingly, you may not safely decide to ignore any particular type of error. For example, it would be incorrect to mask
TlsCertificateFlags.EXPIREDif you want to allow expired certificates, because this could potentially be the only error flag set even if other problems exist with the certificate. Therefore, there is no safe way to use this property. This is not a horrible problem, though, because you should not be attempting to ignore validation errors anyway. If you really must ignore TLS certificate errors, connect to theGSocketClient::event signal, wait for it to be emitted withSocketClientEvent.TLS_HANDSHAKING, and use that to connect toGTlsConnection::accept-certificate.- Parameters:
tlsValidationFlags- the value for thetls-validation-flagsproperty- Returns:
- the
Builderinstance is returned, to allow method chaining
-
onEvent
Emitted whenclient'sactivity onconnectablechanges state. Among other things, this can be used to provide progress information about a network connection in the UI. The meanings of the differenteventvalues are as follows:SocketClientEvent.RESOLVING:clientis about to look upconnectablein DNS.connectionwill benull.
SocketClientEvent.RESOLVED:clienthas successfully resolvedconnectablein DNS.connectionwill benull.
SocketClientEvent.CONNECTING:clientis about to make a connection to a remote host; either a proxy server or the destination server itself.connectionis theGSocketConnection, which is not yet connected. Since GLib 2.40, you can access the remote address via g_socket_connection_get_remote_address().
SocketClientEvent.CONNECTED:clienthas successfully connected to a remote host.connectionis the connectedGSocketConnection.
SocketClientEvent.PROXY_NEGOTIATING:clientis about to negotiate with a proxy to get it to connect toconnectable.connectionis theGSocketConnectionto the proxy server.
SocketClientEvent.PROXY_NEGOTIATED:clienthas negotiated a connection toconnectablethrough a proxy server.connectionis the stream returned from g_proxy_connect(), which may or may not be aGSocketConnection.
SocketClientEvent.TLS_HANDSHAKING:clientis about to begin a TLS handshake.connectionis aGTlsClientConnection.
SocketClientEvent.TLS_HANDSHAKED:clienthas successfully completed the TLS handshake.connectionis aGTlsClientConnection.
SocketClientEvent.COMPLETE:clienthas either successfully connected toconnectable(in which caseconnectionis theGSocketConnectionthat it will be returning to the caller) or has failed (in which caseconnectionisnulland the client is about to return an error).
Each event except
SocketClientEvent.COMPLETEmay be emitted multiple times (or not at all) for a given connectable (in particular, ifclientends up attempting to connect to more than one address). However, ifclientemits theGSocketClient::event signal at all for a given connectable, then it will always emit it withSocketClientEvent.COMPLETEwhen it is done.Note that there may be additional
GSocketClientEventvalues in the future; unrecognizedeventvalues should be ignored.- Parameters:
handler- the signal handler- Returns:
- the
Builderinstance is returned, to allow method chaining - Since:
- 2.32
- See Also:
-