1
0
Fork 0
mirror of https://github.com/dragonfireclient/hydra-dragonfire.git synced 2024-11-21 18:34:00 -05:00
hydra-dragonfire/example/chat-client.lua
Elias Fleckenstein ea4263290b
Event system
2022-05-31 18:10:27 +02:00

26 lines
511 B
Lua
Executable file

#!/usr/bin/env hydra-dragonfire
local escapes = require("escapes")
local client = require("client")()
client:enable("pkts")
client.pkts:subscribe("chat_msg")
client:connect()
while true do
local evt = client:poll(1)
if not evt then
break
end
if not evt or evt.type == "interrupt" or evt.type == "disconnect" then
break
elseif evt.type == "pkt" then
print(escapes.strip_all(evt.pkt_data.text))
elseif evt.type == "timeout" then
client:send("chat_msg", {msg = "test"})
end
end
client:close()