Skip to content

Commit

Permalink
Fixed issue #42
Browse files Browse the repository at this point in the history
Fixed issue #44
Updated dependency eufy-security-client to 1.2.3
  • Loading branch information
bropat committed Nov 16, 2021
1 parent 3cccb2f commit 0b7bdc6
Show file tree
Hide file tree
Showing 5 changed files with 33 additions and 66 deletions.
50 changes: 25 additions & 25 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 3 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "eufy-security-ws",
"version": "0.5.2",
"version": "0.5.3",
"description": "Node WebSocket server implementation to integrate Eufy Security devices",
"main": "dist/lib/index.js",
"bin": {
Expand Down Expand Up @@ -44,15 +44,15 @@
"dependencies": {
"ansi-colors": "^4.1.1",
"commander": "^8.3.0",
"eufy-security-client": "^1.2.2",
"eufy-security-client": "^1.2.3",
"fs-extra": "^10.0.0",
"promptly": "^3.2.0",
"tslog": "^3.2.2",
"ws": "^8.2.3"
},
"devDependencies": {
"@types/ansi-colors": "3.2.2",
"@types/node": "^16.11.6",
"@types/node": "^16.11.7",
"@types/node-rsa": "^1.1.1",
"@types/promptly": "^3.0.2",
"@types/ws": "^8.2.0",
Expand Down
15 changes: 4 additions & 11 deletions src/lib/device/message_handler.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { EufySecurity } from "eufy-security-client";
import { LivestreamAlreadyRunningError, LivestreamNotRunningError, RTSPLivestreamAlreadyRunningError, RTSPLivestreamNotRunningError, UnknownCommandError } from "../error";
import { LivestreamAlreadyRunningError, LivestreamNotRunningError, UnknownCommandError } from "../error";
import { Client } from "../server";
import { DeviceCommand } from "./command";
import { DeviceEvent } from "./event";
Expand Down Expand Up @@ -288,20 +288,13 @@ export class DeviceMessageHandler {
}
case DeviceCommand.startRTSPLivestream:
if (client.schemaVersion >= 6) {
if (!station.isRTSPLiveStreaming(device)) {
await station.startRTSPStream(device).catch((error) => {
throw error;
});
} else {
throw new RTSPLivestreamAlreadyRunningError(`RTSP livestream for device ${serialNumber} is already running`);
}
await station.startRTSPStream(device).catch((error) => {
throw error;
});
return { };
}
case DeviceCommand.stopRTSPLivestream:
if (client.schemaVersion >= 6) {
if (!station.isRTSPLiveStreaming(device)) {
throw new RTSPLivestreamNotRunningError(`RTSP livestream for device ${serialNumber} could not be stopped, because it is not running`);
}
await station.stopRTSPStream(device).catch((error) => {
throw error;
});
Expand Down
18 changes: 0 additions & 18 deletions src/lib/error.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,6 @@ export enum ErrorCode {
deviceInvalidCommandValue = "device_invalid_command_value",
deviceLivestreamAlreadyRunning = "device_livestream_already_running",
deviceLivestreamNotRunning = "device_livestream_not_running",
deviceRTSPLivestreamAlreadyRunning = "device_rtsp_livestream_already_running",
deviceRTSPLivestreamNotRunning = "device_rtsp_livestream_not_running",
schemaIncompatible = "schema_incompatible",
}

Expand Down Expand Up @@ -64,20 +62,4 @@ export class LivestreamNotRunningError extends Error {
Object.setPrototypeOf(this, new.target.prototype);
this.name = LivestreamNotRunningError.name;
}
}

export class RTSPLivestreamAlreadyRunningError extends Error {
constructor(message?: string) {
super(message);
Object.setPrototypeOf(this, new.target.prototype);
this.name = RTSPLivestreamAlreadyRunningError.name;
}
}

export class RTSPLivestreamNotRunningError extends Error {
constructor(message?: string) {
super(message);
Object.setPrototypeOf(this, new.target.prototype);
this.name = RTSPLivestreamNotRunningError.name;
}
}
10 changes: 1 addition & 9 deletions src/lib/server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import { version, minSchemaVersion, maxSchemaVersion } from "./const";
import { DeviceMessageHandler } from "./device/message_handler";
import { StationMessageHandler } from "./station/message_handler";
import { IncomingMessageStation } from "./station/incoming_message";
import { BaseError, ErrorCode, LivestreamAlreadyRunningError, LivestreamNotRunningError, RTSPLivestreamAlreadyRunningError, RTSPLivestreamNotRunningError, SchemaIncompatibleError, UnknownCommandError } from "./error";
import { BaseError, ErrorCode, LivestreamAlreadyRunningError, LivestreamNotRunningError, SchemaIncompatibleError, UnknownCommandError } from "./error";
import { Instance } from "./instance";
import { IncomingMessageDevice } from "./device/incoming_message";
import { ServerCommand } from "./command";
Expand Down Expand Up @@ -157,14 +157,6 @@ export class Client {
this.logger.error("Message error", error);
return this.sendResultError(msg.messageId, ErrorCode.deviceInvalidCommandValue);
}
if (error instanceof RTSPLivestreamAlreadyRunningError) {
this.logger.error("Message error", error);
return this.sendResultError(msg.messageId, ErrorCode.deviceRTSPLivestreamAlreadyRunning);
}
if (error instanceof RTSPLivestreamNotRunningError) {
this.logger.error("Message error", error);
return this.sendResultError(msg.messageId, ErrorCode.deviceRTSPLivestreamNotRunning);
}

this.logger.error("Unexpected error", error as Error);
this.sendResultError(msg.messageId, ErrorCode.unknownError);
Expand Down

0 comments on commit 0b7bdc6

Please sign in to comment.