Software /
code /
verse
Diff
init.lua @ 411:db462d4feb44
verse: trim trailing whitespace
author | Kim Alvefur <zash@zash.se> |
---|---|
date | Tue, 18 Apr 2017 16:46:26 +0200 |
parent | 399:82ad158714e5 |
child | 417:d46a502955c0 |
line wrap: on
line diff
--- 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