09.10.2018, 06:26
Try this for alert stream:
Code:
socket = require('socket')
mime = require('mime')
host = '192.168.1.2'
port = 80
auth = 'user:password'
init = 'GET /ISAPI/Event/notification/alertStream HTTP/1.1\r\n' ..
'Host: ' .. host .. ':' .. port .. '\r\n' ..
'Authorization: Basic ' .. mime.b64(auth) .. '\r\n' ..
'Accept: multipart/x-mixed-replace\r\n\r\n'
sock = socket.tcp()
sock:settimeout(60)
res, err = sock:connect(host, port)
if res then
alert('connection ok')
sock:send(init)
line, err = sock:receive('*l')
log(line, err)
else
alert('connection failed: ' .. tostring(err))
end