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 TypeMethodDescriptionvoidrun(SocketClientEvent event, @Nullable SocketConnectable connectable, @Nullable IOStream connection) Emitted whenclient'sactivity onconnectablechanges state.default MemorySegmenttoCallback(Arena arena) Creates a native function pointer to theupcall(java.lang.foreign.MemorySegment, int, java.lang.foreign.MemorySegment, java.lang.foreign.MemorySegment)method.default voidupcall(MemorySegment sourceSocketClient, int event, MemorySegment connectable, MemorySegment connection) Theupcallmethod is called from native code.
-
Method Details
-
run
void run(SocketClientEvent event, @Nullable SocketConnectable connectable, @Nullable IOStream connection) 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.- Since:
- 2.32
-
upcall
default void upcall(MemorySegment sourceSocketClient, int event, MemorySegment connectable, MemorySegment connection) Theupcallmethod 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:
toCallbackin interfaceFunctionPointer- Parameters:
arena- the arena in which the function pointer is allocated- Returns:
- the native function pointer
-