Package org.gnome.gio
Interface SocketClient.EventCallback
- All Superinterfaces:
FunctionPointer
- Enclosing class:
SocketClient
- Functional Interface:
- This is a functional interface and can therefore be used as the assignment target for a lambda expression or method reference.
Functional interface declaration of the
EventCallback
callback.
- See Also:
-
Method Summary
Modifier and TypeMethodDescriptionvoid
run
(SocketClientEvent event, SocketConnectable connectable, @Nullable IOStream connection) Emitted whenclient
's activity onconnectable
changes state.default MemorySegment
toCallback
(Arena arena) Creates a native function pointer to theupcall(java.lang.foreign.MemorySegment, int, java.lang.foreign.MemorySegment, java.lang.foreign.MemorySegment)
method.default void
upcall
(MemorySegment sourceSocketClient, int event, MemorySegment connectable, MemorySegment connection) Theupcall
method is called from native code.
-
Method Details
-
run
void run(SocketClientEvent event, SocketConnectable connectable, @Nullable @Nullable IOStream connection) Emitted whenclient
's activity onconnectable
changes state. Among other things, this can be used to provide progress information about a network connection in the UI. The meanings of the differentevent
values are as follows:SocketClientEvent.RESOLVING
:client
is about to look upconnectable
in DNS.connection
will benull
.
SocketClientEvent.RESOLVED
:client
has successfully resolvedconnectable
in DNS.connection
will benull
.
SocketClientEvent.CONNECTING
:client
is about to make a connection to a remote host; either a proxy server or the destination server itself.connection
is 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
:client
has successfully connected to a remote host.connection
is the connectedGSocketConnection
.
SocketClientEvent.PROXY_NEGOTIATING
:client
is about to negotiate with a proxy to get it to connect toconnectable
.connection
is theGSocketConnection
to the proxy server.
SocketClientEvent.PROXY_NEGOTIATED
:client
has negotiated a connection toconnectable
through a proxy server.connection
is the stream returned from g_proxy_connect(), which may or may not be aGSocketConnection
.
SocketClientEvent.TLS_HANDSHAKING
:client
is about to begin a TLS handshake.connection
is aGTlsClientConnection
.
SocketClientEvent.TLS_HANDSHAKED
:client
has successfully completed the TLS handshake.connection
is aGTlsClientConnection
.
SocketClientEvent.COMPLETE
:client
has either successfully connected toconnectable
(in which caseconnection
is theGSocketConnection
that it will be returning to the caller) or has failed (in which caseconnection
isnull
and the client is about to return an error).
Each event except
SocketClientEvent.COMPLETE
may be emitted multiple times (or not at all) for a given connectable (in particular, ifclient
ends up attempting to connect to more than one address). However, ifclient
emits theGSocketClient
::event signal at all for a given connectable, then it will always emit it withSocketClientEvent.COMPLETE
when it is done.Note that there may be additional
GSocketClientEvent
values in the future; unrecognizedevent
values should be ignored. -
upcall
default void upcall(MemorySegment sourceSocketClient, int event, MemorySegment connectable, MemorySegment connection) Theupcall
method is called from native code. The parameters are marshaled andrun(org.gnome.gio.SocketClientEvent, org.gnome.gio.SocketConnectable, org.gnome.gio.IOStream)
is executed. -
toCallback
Creates a native function pointer to theupcall(java.lang.foreign.MemorySegment, int, java.lang.foreign.MemorySegment, java.lang.foreign.MemorySegment)
method.- Specified by:
toCallback
in interfaceFunctionPointer
- Parameters:
arena
- the function pointer will be allocated in this arena- Returns:
- the native function pointer
-