Diff

init.lua @ 135:8adf5fb27ce3

verse: Fire disconnected event even if connection fails instantly
author Matthew Wild <mwild1@gmail.com>
date Tue, 14 Sep 2010 15:02:29 +0100
parent 132:b38397163737
child 141:15706f6492ae
line wrap: on
line diff
--- a/init.lua	Mon Sep 13 15:44:22 2010 +0100
+++ b/init.lua	Tue Sep 14 15:02:29 2010 +0100
@@ -67,13 +67,13 @@
 	
 	if not success and err ~= "timeout" then
 		self:warn("connect() to %s:%d failed: %s", connect_host, connect_port, err);
-		return false, err;
+		return self:event("disconnected", { reason = err }) or false, err;
 	end
 
 	local conn = server.wrapclient(conn, connect_host, connect_port, new_listener(self), "*a");
 	if not conn then
 		self:warn("connection initialisation failed: %s", err);
-		return false, err;
+		return self:event("disconnected", { reason = err }) or false, err;
 	end
 	
 	self.conn = conn;