Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: replace threadedclass with comlink #164

Draft
wants to merge 8 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -90,13 +90,13 @@
],
"dependencies": {
"@julusian/freetype2": "^1.1.2",
"comlink": "npm:@superflytv/comlink@^4.4.2",
"debug": "^4.3.4",
"eventemitter3": "^4.0.7",
"exit-hook": "^2.2.1",
"nanotimer": "^0.3.15",
"p-lazy": "^3.1.0",
"p-queue": "^6.6.2",
"threadedclass": "^1.2.1",
"tslib": "^2.6.2",
"wavefile": "^8.4.6"
},
Expand Down
8 changes: 1 addition & 7 deletions src/__tests__/atem.spec.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/* eslint-disable @typescript-eslint/unbound-method */
import { Atem, DEFAULT_MAX_PACKET_SIZE, DEFAULT_PORT } from '../atem'
import { Atem, DEFAULT_MAX_PACKET_SIZE } from '../atem'
import { CutCommand } from '../commands'
import { promisify } from 'util'
import { EventEmitter } from 'events'
Expand Down Expand Up @@ -29,12 +29,9 @@ describe('Atem', () => {

expect(AtemSocket).toHaveBeenCalledTimes(1)
expect(AtemSocket).toHaveBeenCalledWith({
address: '',
childProcessTimeout: 600,
debugBuffers: false,
disableMultithreaded: true,
log: (conn as any)._log,
port: DEFAULT_PORT,
maxPacketSize: DEFAULT_MAX_PACKET_SIZE,
})
} finally {
Expand All @@ -50,12 +47,9 @@ describe('Atem', () => {

expect(AtemSocket).toHaveBeenCalledTimes(1)
expect(AtemSocket).toHaveBeenCalledWith({
address: 'test1',
childProcessTimeout: 600,
debugBuffers: true,
disableMultithreaded: false,
log: (conn as any)._log,
port: 23,
maxPacketSize: 500,
})
} finally {
Expand Down
7 changes: 3 additions & 4 deletions src/__tests__/connection.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
import { readFileSync } from 'fs'
import { resolve } from 'path'
import { AtemSocketChild } from '../lib/atemSocketChild'
import { ThreadedClass } from 'threadedclass'
import { BasicAtem } from '../atem'
import { AtemState, InvalidIdError } from '../state'
import { IDeserializedCommand } from '../commands'
Expand Down Expand Up @@ -58,8 +57,8 @@ function createConnection(): BasicAtem {
})
}

function getChild(conn: BasicAtem): ThreadedClass<AtemSocketChildMock> {
return (conn as any).socket._socketProcess
function getChild(conn: BasicAtem): AtemSocketChildMock {
return (conn as any).socket._socketProcess.wrappedChild
}

function runTest(name: string, filename: string): void {
Expand All @@ -70,7 +69,7 @@ function runTest(name: string, filename: string): void {
describe(name, () => {
test(`Connection`, async () => {
const conn = createConnection()
await conn.connect('')
await conn.connect('127.0.0.1')

const child = getChild(conn)
expect(child).toBeTruthy()
Expand Down
4 changes: 1 addition & 3 deletions src/atem.ts
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ export interface AtemOptions {
port?: number
debugBuffers?: boolean
disableMultithreaded?: boolean
/** @deprecated No longer user */
childProcessTimeout?: number
/**
* Maximum size of packets to transmit
Expand Down Expand Up @@ -107,10 +108,7 @@ export class BasicAtem extends EventEmitter<AtemEvents> {
this._status = AtemConnectionStatus.CLOSED
this.socket = new AtemSocket({
debugBuffers: options?.debugBuffers ?? false,
address: options?.address || '',
port: options?.port || DEFAULT_PORT,
disableMultithreaded: options?.disableMultithreaded ?? false,
childProcessTimeout: options?.childProcessTimeout || 600,
maxPacketSize: options?.maxPacketSize ?? DEFAULT_MAX_PACKET_SIZE,
})
this.dataTransferManager = new DT.DataTransferManager(this.sendCommands.bind(this))
Expand Down
Loading