summaryrefslogtreecommitdiff
path: root/test_client.lua
blob: aac6fe6ab0e6e8c80000394106a89e0497e1bf81 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
#!/usr/bin/env lua5.1
local client = require("client")

local invite = assert(arg[1])
local clt = client.join(invite)
local started

while true do
    client.update(clt)
    local status = client.status(clt)

    if status == "timeout_match" then
        print("failed to connect to match server")
        break
    elseif status == "fail_match" then
        print("game not found (invalid invite?)")
        break
    elseif status == "timeout_server" then
        print("failed to connect to server")
        break
    elseif status == "fail_server" then
        print("incorrect secret (invalid invite?)")
        break
    elseif status == "disco" then
        print("lost connection to server")
        break
    elseif status == "active" and not started then
        started = true
        print("connected to " .. tostring(clt.server))
    end
end

client.close(clt)