From 594706e0af907ea50edfbde8080279a585966c62 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?poljar=20=28Damir=20Jeli=C4=87=29?= Date: Tue, 30 Jan 2018 12:58:50 +0100 Subject: [PATCH] Don't hook the timer hook before we're connected. --- main.py | 9 +++++++++ matrix/socket.py | 17 +++++++++-------- 2 files changed, 18 insertions(+), 8 deletions(-) diff --git a/main.py b/main.py index 066b999..99ef2c4 100644 --- a/main.py +++ b/main.py @@ -225,6 +225,15 @@ def connect_cb(data, status, gnutls_rc, sock, error, ip_address): server.name ) + if not server.timer_hook: + server.timer_hook = W.hook_timer( + 1 * 1000, + 0, + 0, + "matrix_timer_cb", + server.name + ) + server.fd_hook = hook server.connected = True server.connecting = False diff --git a/matrix/socket.py b/matrix/socket.py index 3dd3b07..a151131 100644 --- a/matrix/socket.py +++ b/matrix/socket.py @@ -78,14 +78,15 @@ def connect(server): if not server.server_buffer: create_server_buffer(server) - if not server.timer_hook: - server.timer_hook = W.hook_timer( - 1 * 1000, - 0, - 0, - "matrix_timer_cb", - server.name - ) + ssl_message = " (SSL)" if server.ssl_context.check_hostname else "" + + message = "{prefix}matrix: Connecting to {server}:{port}{ssl}...".format( + prefix=W.prefix("network"), + server=server.address, + port=server.port, + ssl=ssl_message) + + W.prnt(server.server_buffer, message) W.hook_connect("", server.address, server.port, 1, 0, "", "connect_cb", server.name)