diff --git a/tests/client.lua b/tests/client.lua new file mode 100644 index 0000000..e4973f7 --- /dev/null +++ b/tests/client.lua @@ -0,0 +1,28 @@ +local host, port = "ulgrad.ru", 4999 +local json = require('cjson.safe') +local base64 = require('base64') +local socket = require("socket") +local tcp = assert(socket.tcp()) + +tcp:connect(host, port); + + local pack = {} + pack['id'] = 'test' + pack['bme'] = {['temp'] = 10,['press'] = 100,['alt'] = 300} + pack['dht'] = {['temp'] = 12,['humi'] = 67} + pack['uf'] = 5 + + +-- eyJibWUiOnsiYWx0IjozMDAsInRlbXAiOjEwLCJwcmVzcyI6MTAwfSwiZGh0Ijp7Imh1bWkiOjY3LCJ0ZW1wIjoxMn0sInVmIjo1LCJpZCI6InRlc3QifQ== + + +tcp:send(base64.encode(json.encode(pack))) +print(base64.encode(json.encode(pack))) + +while true do + local s, status, partial = tcp:receive() + print(s or partial) + print(status) + if status == "closed" then break end +end +tcp:close() diff --git a/tests/tcp.test b/tests/tcp.test new file mode 100644 index 0000000..e6ced17 --- /dev/null +++ b/tests/tcp.test @@ -0,0 +1,2 @@ +nc meteo.ulgrad.ru 4999 +nc 5.187.7.142 4999