Skip to content
This repository was archived by the owner on Apr 13, 2025. It is now read-only.

Commit 2bd1414

Browse files
Add Atem Service (#286)
* Add Atem Service * Add sample bundle * Add Documentation * Fix Services Count in README * Fix requested changes
1 parent 2b78f80 commit 2bd1414

File tree

8 files changed

+184
-1
lines changed

8 files changed

+184
-1
lines changed

README.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
[![Feature Requests](https://img.shields.io/github/issues/codeoverflow-org/nodecg-io/enhancement?label=Feature%20Requests&style=flat-square)](https://github.com/codeoverflow-org/nodecg-io/labels/enhancement)
44
[![Bugs](https://img.shields.io/github/issues/codeoverflow-org/nodecg-io/bug?label=Bugs&style=flat-square)](https://github.com/codeoverflow-org/nodecg-io/labels/bug)
55
[![Pull Requests](https://img.shields.io/github/issues-pr/codeoverflow-org/nodecg-io?label=Pull%20Requests&style=flat-square)](https://github.com/codeoverflow-org/nodecg-io/pulls)
6-
[![Services](https://img.shields.io/static/v1?label=Services%20implemented&message=38&color=blue&style=flat-square)](https://nodecg.io/RELEASE/services/)
6+
[![Services](https://img.shields.io/static/v1?label=Services%20implemented&message=39&color=blue&style=flat-square)](https://nodecg.io/RELEASE/services/)
77
[![License](https://img.shields.io/github/license/codeoverflow-org/nodecg-io?label=License&style=flat-square)](https://github.com/codeoverflow-org/nodecg-io/blob/master/LICENSE)
88
[![Discord](https://img.shields.io/badge/discord-join-7289DA.svg?logo=discord&style=flat-square)](https://discord.gg/GEJzxBGRu6)
99

@@ -21,6 +21,7 @@ nodecg-io is the successor of [ChatOverflow](https://github.com/codeoverflow-org
2121
- AutoHotkey
2222
- Android (using adb)
2323
- Art-Net
24+
- Atem
2425
- CurseForge
2526
- DBus
2627
- Discord

samples/atem/extension/index.ts

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
import { NodeCG } from "nodecg-types/types/server";
2+
import { requireService } from "nodecg-io-core";
3+
import { AtemServiceClient } from "nodecg-io-atem";
4+
import { Commands } from "atem-connection";
5+
6+
module.exports = function (nodecg: NodeCG) {
7+
nodecg.log.info("Sample bundle for Atem Protocol started.");
8+
9+
const service = requireService<AtemServiceClient>(nodecg, "atem");
10+
11+
service?.onAvailable((client) => {
12+
client.on("connected", () => nodecg.log.info("Atem connected to server."));
13+
client.on("receivedCommands", (e: Commands.IDeserializedCommand[]) => nodecg.log.info(e));
14+
client.on("error", (e) => nodecg.log.error(e));
15+
});
16+
17+
service?.onUnavailable(() => {
18+
nodecg.log.info("Connect to Atem server closed.");
19+
});
20+
};

samples/atem/package.json

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
{
2+
"name": "atem",
3+
"homepage": "https://nodecg.io/RELEASE/samples/atem",
4+
"author": {
5+
"name": "Extrem Techniker",
6+
"url": "https://github.com/ExtremTechniker"
7+
},
8+
"repository": {
9+
"type": "git",
10+
"url": "https://github.com/codeoverflow-org/nodecg-io.git",
11+
"directory": "samples/atem"
12+
},
13+
"version": "0.2.0",
14+
"private": true,
15+
"nodecg": {
16+
"compatibleRange": "^1.1.1",
17+
"bundleDependencies": {
18+
"nodecg-io-atem": "^0.2.0"
19+
}
20+
},
21+
"license": "MIT",
22+
"dependencies": {
23+
"@types/node": "^16.11.6",
24+
"nodecg-types": "^1.8.3",
25+
"nodecg-io-core": "^0.2.0",
26+
"nodecg-io-atem": "^0.2.0",
27+
"typescript": "^4.4.4"
28+
}
29+
}

samples/atem/tsconfig.json

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
{
2+
"extends": "../../tsconfig.common.json",
3+
"references": [
4+
{
5+
"path": "../../nodecg-io-core"
6+
},
7+
{
8+
"path": "../../services/nodecg-io-atem"
9+
}
10+
]
11+
}
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
{
2+
"$schema": "http://json-schema.org/draft-07/schema#",
3+
"type": "object",
4+
"additionalProperties": false,
5+
"properties": {
6+
"address": {
7+
"type": "string",
8+
"description": "An IP address to the Atem server"
9+
},
10+
"port": {
11+
"type": "number",
12+
"description": "The port of the Atem server"
13+
},
14+
"debugBuffers": {
15+
"type": "boolean",
16+
"description": "Enables debug buffers"
17+
},
18+
"disableMultithreaded": {
19+
"type": "boolean",
20+
"description": "Disable mulithreaded tasks"
21+
},
22+
"childProcessTimeout": {
23+
"type": "number",
24+
"description": "Set child proccess timeout"
25+
}
26+
},
27+
"required": ["address"]
28+
}
Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
import { NodeCG } from "nodecg-types/types/server";
2+
import { Result, emptySuccess, success, error, ServiceBundle } from "nodecg-io-core";
3+
import { Atem } from "atem-connection";
4+
5+
interface AtemServiceConfig {
6+
address: string;
7+
port?: number;
8+
debugBuffers?: boolean;
9+
disableMultithreaded?: boolean;
10+
childProcessTimeout?: number;
11+
}
12+
13+
export type AtemServiceClient = Atem;
14+
15+
module.exports = (nodecg: NodeCG) => {
16+
new AtemService(nodecg, "atem", __dirname, "../atem-schema.json").register();
17+
};
18+
19+
class AtemService extends ServiceBundle<AtemServiceConfig, AtemServiceClient> {
20+
async validateConfig(config: AtemServiceConfig): Promise<Result<void>> {
21+
return new Promise((resolve, reject) => {
22+
const atem = new Atem(config);
23+
atem.connect(config.address, config.port);
24+
atem.on("connected", () => resolve(emptySuccess()));
25+
atem.on("error", (e) => reject(error(e)));
26+
});
27+
}
28+
29+
async createClient(config: AtemServiceConfig): Promise<Result<AtemServiceClient>> {
30+
return new Promise((resolve, _) => {
31+
const atem = new Atem(config);
32+
atem.connect(config.address, config.port);
33+
atem.on("connected", () => resolve(success(atem)));
34+
});
35+
}
36+
37+
stopClient(client: AtemServiceClient) {
38+
client.disconnect();
39+
}
40+
41+
removeHandlers(client: AtemServiceClient) {
42+
client.removeAllListeners();
43+
}
44+
}
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
{
2+
"name": "nodecg-io-atem",
3+
"version": "0.2.0",
4+
"description": "Allows to connect via the Atem Protocol.",
5+
"homepage": "https://nodecg.io/RELEASE/samples/atem",
6+
"author": {
7+
"name": "Extrem Techniker",
8+
"url": "https://github.com/ExtremTechniker"
9+
},
10+
"main": "extension/index",
11+
"repository": {
12+
"type": "git",
13+
"url": "https://github.com/codeoverflow-org/nodecg-io.git",
14+
"directory": "services/nodecg-io-atem"
15+
},
16+
"files": [
17+
"**/*.js",
18+
"**/*.js.map",
19+
"**/*.d.ts",
20+
"*.json"
21+
],
22+
"keywords": [
23+
"nodecg-io",
24+
"nodecg-bundle"
25+
],
26+
"nodecg": {
27+
"compatibleRange": "^1.1.1",
28+
"bundleDependencies": {
29+
"nodecg-io-core": "^0.2.0"
30+
}
31+
},
32+
"license": "MIT",
33+
"devDependencies": {
34+
"@types/node": "^16.11.6",
35+
"nodecg-types": "^1.8.3",
36+
"typescript": "^4.4.4"
37+
},
38+
"dependencies": {
39+
"atem-connection": "^2.3.1",
40+
"nodecg-io-core": "^0.2.0"
41+
}
42+
}
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
{
2+
"extends": "../../tsconfig.common.json",
3+
"references": [
4+
{
5+
"path": "../../nodecg-io-core"
6+
}
7+
]
8+
}

0 commit comments

Comments
 (0)