mudgangster

Tiny, scriptable MUD client
Log | Files | Refs | README

commit c27d4b9fd265a81ec55ae8f5df134d619719bc97
parent d4bb126b484b9ac4bdbe1064ad887f03d2cad34b
Author: Michael Savage <mikejsavage@gmail.com>
Date:   Sat,  9 May 2020 12:01:40 +0300

Little cleanup

Diffstat:
Msrc/lua/chat.lua | 40+++++++++++++++++-----------------------
1 file changed, 17 insertions(+), 23 deletions(-)

diff --git a/src/lua/chat.lua b/src/lua/chat.lua @@ -91,27 +91,6 @@ local function dataCoro( chat ) end end -local function newChat( sock, address, port ) - local chat = { - name = address .. ":" .. port, - socket = sock, - - address = address, - port = port, - - state = "connecting", - handler = coroutine.create( dataCoro ), - } - - assert( coroutine.resume( chat.handler, chat ) ) - - table.insert( Chats, chat ) - - socket.send( sock, "CHAT:%s\n127.0.0.14050 " % chatName ) - - return chat -end - local function dataHandler( chat, loop, watcher ) local _, err, data = chat.socket:receive( "*a" ) @@ -160,8 +139,23 @@ local function call( address, port ) return end - chat = newChat( sock, address, port ) - socket.send( chat.socket, CommandBytes.version .. "MudGangster" .. "\255" ) + local chat = { + name = address .. ":" .. port, + socket = sock, + + address = address, + port = port, + + state = "connecting", + handler = coroutine.create( dataCoro ), + } + + assert( coroutine.resume( chat.handler, chat ) ) + + table.insert( Chats, chat ) + + socket.send( sock, "CHAT:%s\n127.0.0.14050 " % chatName ) + socket.send( sock, CommandBytes.version .. "MudGangster\255" ) end mud.alias( "/call", {