Trait gio::prelude::SocketServiceExt
source · pub trait SocketServiceExt: IsA<SocketService> + Sealed + 'static {
// Provided methods
fn is_active(&self) -> bool { ... }
fn start(&self) { ... }
fn stop(&self) { ... }
fn set_active(&self, active: bool) { ... }
fn connect_incoming<F: Fn(&Self, &SocketConnection, Option<&Object>) -> bool + 'static>(
&self,
f: F
) -> SignalHandlerId { ... }
fn connect_active_notify<F: Fn(&Self) + 'static>(
&self,
f: F
) -> SignalHandlerId { ... }
}
Expand description
Provided Methods§
sourcefn start(&self)
fn start(&self)
Restarts the service, i.e. start accepting connections
from the added sockets when the mainloop runs. This only needs
to be called after the service has been stopped from
stop()
.
This call is thread-safe, so it may be called from a thread handling an incoming client request.
sourcefn stop(&self)
fn stop(&self)
Stops the service, i.e. stops accepting connections from the added sockets when the mainloop runs.
This call is thread-safe, so it may be called from a thread handling an incoming client request.
Note that this only stops accepting new connections; it does not
close the listening sockets, and you can call
start()
again later to begin listening again. To
close the listening sockets, call SocketListenerExt::close()
. (This
will happen automatically when the SocketService
is finalized.)
This must be called before calling SocketListenerExt::close()
as
the socket service will start accepting connections immediately
when a new socket is added.
sourcefn set_active(&self, active: bool)
fn set_active(&self, active: bool)
Whether the service is currently accepting connections.
sourcefn connect_incoming<F: Fn(&Self, &SocketConnection, Option<&Object>) -> bool + 'static>(
&self,
f: F
) -> SignalHandlerId
fn connect_incoming<F: Fn(&Self, &SocketConnection, Option<&Object>) -> bool + 'static>( &self, f: F ) -> SignalHandlerId
The ::incoming signal is emitted when a new incoming connection
to service
needs to be handled. The handler must initiate the
handling of connection
, but may not block; in essence,
asynchronous operations must be used.
connection
will be unreffed once the signal handler returns,
so you need to ref it yourself if you are planning to use it.
connection
a new SocketConnection
object
source_object
the source_object passed to
SocketListenerExt::add_address()
Returns
true
to stop other handlers from being called