diff options
| author | Elias Fleckenstein <eliasfleckenstein@web.de> | 2022-05-29 23:09:53 +0200 |
|---|---|---|
| committer | Elias Fleckenstein <eliasfleckenstein@web.de> | 2022-05-29 23:09:53 +0200 |
| commit | e8c35eb2780cf17890f2905f44d1a1d170c40b37 (patch) | |
| tree | d5e80c11f6ca1f46eb1ae3aa88a3e2c8e2507597 /example | |
| parent | 535595e9823f020b8f02ae657f259966814d1906 (diff) | |
| download | hydra-dragonfire-e8c35eb2780cf17890f2905f44d1a1d170c40b37.tar.xz | |
Implement sending of packets
Diffstat (limited to 'example')
| -rwxr-xr-x | example/chat-client.lua | 13 | ||||
| -rwxr-xr-x | example/dump-traffic.lua | 9 |
2 files changed, 7 insertions, 15 deletions
diff --git a/example/chat-client.lua b/example/chat-client.lua index 7acb9a6..b1bd505 100755 --- a/example/chat-client.lua +++ b/example/chat-client.lua @@ -1,21 +1,18 @@ #!/usr/bin/env hydra-dragonfire local escapes = require("escapes") -local address, name, password = unpack(arg) -local client = hydra.client(address) - -client:enable("auth") -client.auth:username(name) -client.auth:password(password or "") +local client = require("client")() client:subscribe("chat_msg") client:connect() while not hydra.canceled() do - local pkt, interrupt = client:poll() + local pkt, interrupt = client:poll(1) if pkt then print(escapes.strip_all(pkt.text)) - elseif not interrupt then + elseif interrupt then + client:send("chat_msg", {msg = "test"}) + else print("disconnected") break end diff --git a/example/dump-traffic.lua b/example/dump-traffic.lua index 1fd4316..648aa4d 100755 --- a/example/dump-traffic.lua +++ b/example/dump-traffic.lua @@ -1,10 +1,5 @@ #!/usr/bin/env hydra-dragonfire -local address, name, password = unpack(arg) -local client = hydra.client(address) - -client:enable("auth") -client.auth:username(name) -client.auth:password(password or "") +local client = require("client")() client:wildcard(true) client:connect() @@ -21,7 +16,7 @@ while not hydra.canceled() do end elseif not interrupt then print("disconnected") - break + break end end |
