From 90856a67fa2fa8061254006974b8921b4e97bc1a Mon Sep 17 00:00:00 2001 From: rebecca Date: Sat, 12 Sep 2026 18:58:49 +0100 Subject: more oop refactoring --- nanochat_send/pylon.lua | 24 +++++++++++------------- 1 file changed, 11 insertions(+), 13 deletions(-) (limited to 'nanochat_send/pylon.lua') diff --git a/nanochat_send/pylon.lua b/nanochat_send/pylon.lua index 0e57763..f7cd60f 100644 --- a/nanochat_send/pylon.lua +++ b/nanochat_send/pylon.lua @@ -1,25 +1,23 @@ -local Queue = require 'queue' local cqueues = require 'cqueues' -local pylon = require 'pylon' -local pprint = require 'pprint' -local Channel = require 'channel' local socket = require 'cqueues.socket' +local pprint = require 'pprint' +local class = require 'r.class' -local NanochatSend = pylon.subclass "nanochat_send" +local BasePylon = require 'pylon' +local Channel = require 'channel' +local NanochatSend = class.extend(BasePylon) function NanochatSend:init() - self:check_config "server port poll" + self:_check_fields "server port poll" end function NanochatSend:_connect() - if not self.sock then - self.sock = socket.connect(self.server, tonumber(self.port)) - self.sock:write("LAST 0\n") - self.sock:read("*l") -- discard count - self.lastid = tonumber(assert(self.sock:read("*l"))) - self.usids = {} - end + self.sock = socket.connect(self.server, tonumber(self.port)) + self.sock:write("LAST 0\n") + self.sock:read("*l") -- discard count + self.lastid = tonumber(assert(self.sock:read("*l"))) + self.usids = {} end function NanochatSend:add_channel(channel) -- cgit v1.2.3