Changeset

417:d46a502955c0

verse: Remove use of deprecated module() function
author Kim Alvefur <zash@zash.se>
date Sun, 20 May 2018 01:16:22 +0200 (2018-05-19)
parents 416:92ce569b9b73
children 418:40b8cc364274
files init.lua
diffstat 1 files changed, 9 insertions(+), 10 deletions(-) [+]
line wrap: on
line diff
--- a/init.lua	Sun May 20 01:15:50 2018 +0200
+++ b/init.lua	Sun May 20 01:16:22 2018 +0200
@@ -11,13 +11,12 @@
 local events = require "util.events";
 local logger = require "util.logger";
 
-module("verse", package.seeall);
-local verse = _M;
-_M.server = server;
+local verse = {};
+verse.server = server;
 
 local stream = {};
 stream.__index = stream;
-stream_mt = stream;
+verse.stream_mt = stream;
 
 verse.plugins = {};
 
@@ -75,10 +74,10 @@
 	end
 end
 
-function _default_log_handler(name, level, message)
+function verse._default_log_handler(name, level, message)
 	return io.stderr:write(name, "\t", level, "\t", message, "\n");
 end
-verse.set_log_handler(_default_log_handler, { "error" });
+verse.set_log_handler(verse._default_log_handler, { "error" });
 
 local function error_handler(err)
 	verse.log("error", "Error: %s", err);
@@ -104,7 +103,7 @@
 function stream:listen(host, port)
 	host = host or "localhost";
 	port = port or 0;
-	local conn, err = server.addserver(host, port, new_listener(self, "server"), "*a");
+	local conn, err = server.addserver(host, port, verse.new_listener(self, "server"), "*a");
 	if conn then
 		self:debug("Bound to %s:%s", host, port);
 		self.server = conn;
@@ -127,7 +126,7 @@
 		return self:event("disconnected", { reason = err }) or false, err;
 	end
 
-	local conn = server.wrapclient(conn, connect_host, connect_port, new_listener(self), "*a");
+	local conn = server.wrapclient(conn, connect_host, connect_port, verse.new_listener(self), "*a");
 	if not conn then
 		self:warn("connection initialisation failed: %s", err);
 		return self:event("disconnected", { reason = err }) or false, err;
@@ -212,13 +211,13 @@
 end
 
 -- Listener factory
-function new_listener(stream)
+function verse.new_listener(stream)
 	local conn_listener = {};
 
 	function conn_listener.onconnect(conn)
 		if stream.server then
 			local client = verse.new();
-			conn:setlistener(new_listener(client));
+			conn:setlistener(verse.new_listener(client));
 			client:set_conn(conn);
 			stream:event("connected", { client = client });
 		else