fritz-callmonitor
Advanced tools
Comparing version 3.0.0 to 3.0.2
@@ -48,3 +48,3 @@ /// <reference types="node" /> | ||
} | ||
export declare const enum EventKind { | ||
export declare enum EventKind { | ||
Call = 0, | ||
@@ -51,0 +51,0 @@ Ring = 1, |
"use strict"; | ||
var __assign = (this && this.__assign) || Object.assign || function(t) { | ||
for (var s, i = 1, n = arguments.length; i < n; i++) { | ||
s = arguments[i]; | ||
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) | ||
t[p] = s[p]; | ||
} | ||
return t; | ||
}; | ||
const byline_1 = require("byline"); | ||
@@ -16,12 +24,12 @@ const net_1 = require("net"); | ||
s.connect(this.port, this.host); | ||
s.on("connect", args => { | ||
s.on("connect", () => { | ||
const reader = byline_1.createStream(this._socket, { encoding: "utf-8" }); | ||
reader.on("data", (l) => this.processLine(l)); | ||
s.once("end", _ => reader.end()); | ||
this.emit("connect", args); | ||
s.once("end", () => reader.end()); | ||
this.emit("connect"); | ||
}); | ||
s.on("end", args => this.emit("end", args)); | ||
s.on("timeout", args => this.emit("timeout", args)); | ||
s.on("end", () => this.emit("end")); | ||
s.on("timeout", () => this.emit("timeout")); | ||
s.on("error", err => this.emit("error", err)); | ||
s.on("close", args => this.emit("close", args)); | ||
s.on("close", had_error => this.emit("close", had_error)); | ||
} | ||
@@ -37,6 +45,6 @@ end() { | ||
switch (data.kind) { | ||
case 1: return this.emit("ring", data); | ||
case 0: return this.emit("call", data); | ||
case 2: return this.emit("pickup", data); | ||
case 4: return this.emit("hangup", data); | ||
case EventKind.Ring: return this.emit("ring", data); | ||
case EventKind.Call: return this.emit("call", data); | ||
case EventKind.PickUp: return this.emit("pickup", data); | ||
case EventKind.HangUp: return this.emit("hangup", data); | ||
default: return false; | ||
@@ -55,26 +63,10 @@ } | ||
switch (eventKind) { | ||
case 4: | ||
return Object.assign(res, { | ||
kind: eventKind, | ||
callDuration: parseInt(splitLines[3]) | ||
}); | ||
case 0: | ||
return Object.assign(res, { | ||
kind: eventKind, | ||
extension: splitLines[3], | ||
caller: splitLines[4], | ||
callee: splitLines[5] | ||
}); | ||
case 2: | ||
return Object.assign(res, { | ||
kind: eventKind, | ||
extension: splitLines[3], | ||
phoneNumber: splitLines[4] | ||
}); | ||
case 1: | ||
return Object.assign(res, { | ||
kind: eventKind, | ||
caller: splitLines[3], | ||
callee: splitLines[4] | ||
}); | ||
case EventKind.HangUp: | ||
return __assign({}, res, { kind: eventKind, callDuration: parseInt(splitLines[3]) }); | ||
case EventKind.Call: | ||
return __assign({}, res, { kind: eventKind, extension: splitLines[3], caller: splitLines[4], callee: splitLines[5] }); | ||
case EventKind.PickUp: | ||
return __assign({}, res, { kind: eventKind, extension: splitLines[3], phoneNumber: splitLines[4] }); | ||
case EventKind.Ring: | ||
return __assign({}, res, { kind: eventKind, caller: splitLines[3], callee: splitLines[4] }); | ||
} | ||
@@ -98,6 +90,6 @@ } | ||
switch (ev.toUpperCase()) { | ||
case "RING": return 1; | ||
case "CALL": return 0; | ||
case "CONNECT": return 2; | ||
case "DISCONNECT": return 4; | ||
case "RING": return EventKind.Ring; | ||
case "CALL": return EventKind.Call; | ||
case "CONNECT": return EventKind.PickUp; | ||
case "DISCONNECT": return EventKind.HangUp; | ||
default: return undefined; | ||
@@ -108,1 +100,8 @@ } | ||
exports.CallMonitor = CallMonitor; | ||
var EventKind; | ||
(function (EventKind) { | ||
EventKind[EventKind["Call"] = 0] = "Call"; | ||
EventKind[EventKind["Ring"] = 1] = "Ring"; | ||
EventKind[EventKind["PickUp"] = 2] = "PickUp"; | ||
EventKind[EventKind["HangUp"] = 4] = "HangUp"; | ||
})(EventKind = exports.EventKind || (exports.EventKind = {})); |
{ | ||
"name": "fritz-callmonitor", | ||
"version": "3.0.0", | ||
"version": "3.0.2", | ||
"description": "Provides a node.js wrapper for the call monitor api of the AVM Fritz!Box. Written in TypeScript.", | ||
@@ -13,7 +13,7 @@ "main": "dist/lib.js", | ||
"devDependencies": { | ||
"typescript": "^2.0.3" | ||
"typescript": "^2.1.0" | ||
}, | ||
"scripts": { | ||
"prepublish": "tsc", | ||
"test": "tsc" | ||
"prepublish": "./node_modules/.bin/tsc", | ||
"test": "./node_modules/.bin/tsc" | ||
}, | ||
@@ -23,3 +23,2 @@ "license": "LGPL-3.0", | ||
"@types/byline": "^4.2.30", | ||
"@types/moment": "^2.13.0", | ||
"byline": "^4.2", | ||
@@ -26,0 +25,0 @@ "moment": "^2.8" |
@@ -5,3 +5,3 @@ # fritz-callmonitor | ||
## Installation | ||
``` | ||
```Shell | ||
npm install fritz-callmonitor | ||
@@ -11,3 +11,3 @@ ``` | ||
### TypeScript Usage | ||
Copy the `fritz-callmonitor.d.ts` from `node_modules/fritz-callmonitor` to your TypeScript directory and make a reference using `///`. | ||
You need TypeScript 2. Just install the NPM package and you're ready to go! | ||
@@ -14,0 +14,0 @@ ## Enabling the API |
16820
3
13
188
- Removed@types/moment@^2.13.0
- Removed@types/moment@2.13.0(transitive)