Skip to content
This repository has been archived by the owner on Apr 12, 2020. It is now read-only.

Commit

Permalink
Added ping functionality.
Browse files Browse the repository at this point in the history
  • Loading branch information
eloylp committed Apr 29, 2018
1 parent af17980 commit 09a5565
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 0 deletions.
7 changes: 7 additions & 0 deletions lib/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,13 @@ class PakistranoCameraControl {
this._checkCameraResponse(await request.get(this._getUrlCommand(94).toString()))
}

async ping () {
const before = new Date().getMilliseconds()
await this.getSnapshot()
const after = new Date().getMilliseconds()
return after - before
}

getVideoStream () {
return new Promise((resolve) => {
const url = this._getUrlMedia('/videostream.cgi').url
Expand Down
8 changes: 8 additions & 0 deletions test/ping.test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
const test = require('ava')
const pakistranoCameraControl = require('../lib/pakistranoFactory')

test('Ping integration test.', async (t) => {
const ms = await pakistranoCameraControl.ping()
t.is('number', typeof ms)
t.true(ms > 0)
})

0 comments on commit 09a5565

Please sign in to comment.