Add connection indicator to client
This commit is contained in:
parent
7c26a9278f
commit
5912302043
@ -12,8 +12,38 @@ namespace StudySystemClient {
|
||||
header_bar.title_widget = title;
|
||||
set_titlebar(header_bar);
|
||||
|
||||
var connection_indicator = new ConnectionIndicator(client);
|
||||
var activities_view = new ActivitiesView(client);
|
||||
set_child(activities_view);
|
||||
|
||||
var content = new Gtk.Box(Gtk.Orientation.VERTICAL, 0);
|
||||
content.append(connection_indicator);
|
||||
content.append(activities_view);
|
||||
|
||||
set_child(content);
|
||||
}
|
||||
}
|
||||
|
||||
private class ConnectionIndicator : Gtk.Box {
|
||||
public ConnectionIndicator(Client client) {
|
||||
var icon
|
||||
= new Gtk.Image.from_icon_name("network-offline-symbolic");
|
||||
var label = new Gtk.Label("Disconnected");
|
||||
|
||||
var content = new Gtk.Box(Gtk.Orientation.HORIZONTAL, 8);
|
||||
content.margin_top = content.margin_bottom
|
||||
= content.margin_start = content.margin_end = 12;
|
||||
content.hexpand = true;
|
||||
content.halign = Gtk.Align.CENTER;
|
||||
content.append(icon);
|
||||
content.append(label);
|
||||
|
||||
var revealer = new Gtk.Revealer();
|
||||
revealer.set_child(content);
|
||||
append(revealer);
|
||||
|
||||
client.connection_status.connect((connected) => {
|
||||
revealer.reveal_child = !connected;
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -3,7 +3,7 @@ namespace StudySystemClient {
|
||||
public delegate void ReceiveCallback(owned uint8[] msg);
|
||||
|
||||
private const uint INIT_RECONNECT_WAIT_MS = 500;
|
||||
private const uint MAX_RECONNECT_WAIT_MS = 60000;
|
||||
private const uint MAX_RECONNECT_WAIT_MS = 30000;
|
||||
private const double RECONNECT_BACKOFF = 1.6;
|
||||
|
||||
private SessionFactory session_factory;
|
||||
@ -72,7 +72,7 @@ namespace StudySystemClient {
|
||||
public class SessionFactory {
|
||||
private const string CA_FILENAME = "/ca.pem";
|
||||
private const string CERT_FILENAME = "/client.pem";
|
||||
private const uint TIMEOUT_S = 1;
|
||||
private const uint TIMEOUT_S = 2;
|
||||
|
||||
private InetSocketAddress host;
|
||||
private TlsCertificate cert;
|
||||
|
Loading…
x
Reference in New Issue
Block a user