verse: trim trailing whitespace

Tue, 18 Apr 2017 16:46:26 +0200

author
Kim Alvefur <zash@zash.se>
date
Tue, 18 Apr 2017 16:46:26 +0200
changeset 411
db462d4feb44
parent 410
6171ef2a4025
child 412
ef66f302fe97

verse: trim trailing whitespace

bosh.lua file | annotate | diff | comparison | revisions
client.lua file | annotate | diff | comparison | revisions
component.lua file | annotate | diff | comparison | revisions
init.lua file | annotate | diff | comparison | revisions
--- a/bosh.lua	Fri Apr 07 19:39:59 2017 +0200
+++ b/bosh.lua	Tue Apr 18 16:46:26 2017 +0200
@@ -64,7 +64,7 @@
 			self.inactive_since = nil;
 			return self:_handle_response(response, code, request);
 		end
-		
+
 		-- Connection issues, we need to retry this request
 		local time = os.time();
 		if not self.inactive_since then
@@ -72,10 +72,10 @@
 		elseif time - self.inactive_since > self.bosh_max_inactivity then
 			return self:_disconnected();
 		else
-			self:debug("%d seconds left to reconnect, retrying in %d seconds...", 
+			self:debug("%d seconds left to reconnect, retrying in %d seconds...",
 				self.bosh_max_inactivity - (time - self.inactive_since), reconnect_timeout);
 		end
-		
+
 		-- Set up reconnect timer
 		timer.add_task(reconnect_timeout, function ()
 			self:debug("Retrying request...");
@@ -103,7 +103,7 @@
 
 function stream_mt:_send_session_request()
 	local body = self:_make_body();
-	
+
 	-- XEP-0124
 	body.attr.hold = "1";
 	body.attr.wait = "60";
@@ -114,7 +114,7 @@
 	body.attr.from = self.jid;
 	body.attr.to = self.host;
 	body.attr.secure = 'true';
-	
+
 	http.request(self.bosh_url, { body = tostring(body) }, function (response, code)
 		if code == 0 then
 			-- Failed to connect
--- a/client.lua	Fri Apr 07 19:39:59 2017 +0200
+++ b/client.lua	Tue Apr 18 16:46:26 2017 +0200
@@ -22,7 +22,7 @@
 	stream_ns = xmlns_stream,
 	stream_tag = "stream",
 	 default_ns = "jabber:client" };
-	
+
 function stream_callbacks.streamopened(stream, attr)
 	stream.stream_id = attr.id;
 	if not stream:event("opened", attr) then
@@ -76,25 +76,25 @@
 function stream:connect_client(jid, pass)
 	self.jid, self.password = jid, pass;
 	self.username, self.host, self.resource = jid_split(jid);
-	
+
 	-- Required XMPP features
 	self:add_plugin("tls");
 	self:add_plugin("sasl");
 	self:add_plugin("bind");
 	self:add_plugin("session");
-	
+
 	function self.data(conn, data)
 		local ok, err = self.stream:feed(data);
 		if ok then return; end
 		self:debug("Received invalid XML (%s) %d bytes: %s", tostring(err), #data, data:sub(1, 300):gsub("[\r\n]+", " "));
 		self:close("xml-not-well-formed");
 	end
-	
+
 	self:hook("connected", function () self:reopen(); end);
 	self:hook("incoming-raw", function (data) return self.data(self.conn, data); end);
-	
+
 	self.curr_id = 0;
-	
+
 	self.tracked_iqs = {};
 	self:hook("stanza", function (stanza)
 		local id, type = stanza.attr.id, stanza.attr.type;
@@ -104,7 +104,7 @@
 			return true;
 		end
 	end);
-	
+
 	self:hook("stanza", function (stanza)
 		local ret;
 		if stanza.attr.xmlns == nil or stanza.attr.xmlns == "jabber:client" then
@@ -132,13 +132,13 @@
 			self:event("stanza-out", data);
 		end
 	end);
-	
+
 	self:hook("stanza-out", function (stanza)
 		if not stanza.attr.xmlns then
 			self:event(stanza.name.."-out", stanza);
 		end
 	end);
-	
+
 	local function stream_ready()
 		self:event("ready");
 	end
@@ -155,12 +155,12 @@
 			return self:close(reason);
 		end
 	end
-	
+
 	local function start_connect()
 		-- Initialise connection
 		self:connect(self.connect_host or self.host, self.connect_port or 5222);
 	end
-	
+
 	if not (self.connect_host or self.connect_port) then
 		-- Look up SRV records
 		adns.lookup(function (answer)
@@ -171,14 +171,14 @@
 					table.insert(srv_hosts, record.srv);
 				end
 				table.sort(srv_hosts, compare_srv_priorities);
-				
+
 				local srv_choice = srv_hosts[1];
 				self.srv_choice = 1;
 				if srv_choice then
 					self.connect_host, self.connect_port = srv_choice.target, srv_choice.port;
 					self:debug("Best record found, will connect to %s:%d", self.connect_host or self.host, self.connect_port or 5222);
 				end
-				
+
 				self:hook("disconnected", function ()
 					if self.srv_hosts and self.srv_choice < #self.srv_hosts then
 						self.srv_choice = self.srv_choice + 1;
@@ -188,7 +188,7 @@
 						return true;
 					end
 				end, 1000);
-				
+
 				self:hook("connected", function ()
 					self.srv_hosts = nil;
 				end, 1000);
--- a/component.lua	Fri Apr 07 19:39:59 2017 +0200
+++ b/component.lua	Tue Apr 18 16:46:26 2017 +0200
@@ -19,7 +19,7 @@
 	stream_ns = xmlns_stream,
 	stream_tag = "stream",
 	 default_ns = xmlns_component };
-	
+
 function stream_callbacks.streamopened(stream, attr)
 	stream.stream_id = attr.id;
 	if not stream:event("opened", attr) then
@@ -55,18 +55,18 @@
 function stream:connect_component(jid, pass)
 	self.jid, self.password = jid, pass;
 	self.username, self.host, self.resource = jid_split(jid);
-	
+
 	function self.data(conn, data)
 		local ok, err = self.stream:feed(data);
 		if ok then return; end
 		stream:debug("Received invalid XML (%s) %d bytes: %s", tostring(err), #data, data:sub(1, 300):gsub("[\r\n]+", " "));
 		stream:close("xml-not-well-formed");
 	end
-	
+
 	self:hook("incoming-raw", function (data) return self.data(self.conn, data); end);
-	
+
 	self.curr_id = 0;
-	
+
 	self.tracked_iqs = {};
 	self:hook("stanza", function (stanza)
 		local id, type = stanza.attr.id, stanza.attr.type;
@@ -76,7 +76,7 @@
 			return true;
 		end
 	end);
-	
+
 	self:hook("stanza", function (stanza)
 		local ret;
 		if stanza.attr.xmlns == nil or stanza.attr.xmlns == "jabber:client" then
--- a/init.lua	Fri Apr 07 19:39:59 2017 +0200
+++ b/init.lua	Tue Apr 18 16:46:26 2017 +0200
@@ -115,13 +115,13 @@
 function stream:connect(connect_host, connect_port)
 	connect_host = connect_host or "localhost";
 	connect_port = tonumber(connect_port) or 5222;
-	
+
 	-- Create and initiate connection
 	local conn = socket.tcp()
 	conn:settimeout(0);
 	conn:setoption("keepalive", true);
 	local success, err = conn:connect(connect_host, connect_port);
-	
+
 	if not success and err ~= "timeout" then
 		self:warn("connect() to %s:%d failed: %s", connect_host, connect_port, err);
 		return self:event("disconnected", { reason = err }) or false, err;
@@ -147,7 +147,7 @@
 end
 
 function stream:close(reason)
-	if not self.conn then 
+	if not self.conn then
 		verse.log("error", "Attempt to close disconnected connection - possibly a bug");
 		return;
 	end
@@ -214,7 +214,7 @@
 -- Listener factory
 function new_listener(stream)
 	local conn_listener = {};
-	
+
 	function conn_listener.onconnect(conn)
 		if stream.server then
 			local client = verse.new();
@@ -226,11 +226,11 @@
 			stream:event("connected");
 		end
 	end
-	
+
 	function conn_listener.onincoming(conn, data)
 		stream:event("incoming-raw", data);
 	end
-	
+
 	function conn_listener.ondisconnect(conn, err)
 		if conn ~= stream.conn then return end
 		stream.connected = false;
@@ -240,11 +240,11 @@
 	function conn_listener.ondrain(conn)
 		stream:event("drained");
 	end
-	
+
 	function conn_listener.onstatus(conn, new_status)
 		stream:event("status", new_status);
 	end
-	
+
 	return conn_listener;
 end
 

mercurial