Skip to content

Commit

Permalink
Merge pull request #82 from istnv/c3.3
Browse files Browse the repository at this point in the history
lib update for v3.3
  • Loading branch information
istnv authored May 3, 2024
2 parents 7778eed + e1734d2 commit 8766624
Show file tree
Hide file tree
Showing 3 changed files with 3,019 additions and 2,186 deletions.
6 changes: 3 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "generic-pjlink",
"version": "2.2.1",
"version": "2.3.0",
"main": "pjlink.js",
"type": "module",
"scripts": {
Expand All @@ -12,9 +12,9 @@
"url": "git+https://github.com/bitfocus/companion-module-generic-pjlink.git"
},
"dependencies": {
"@companion-module/base": "^1.7.0"
"@companion-module/base": "^1.8.0"
},
"devDependencies": {
"@companion-module/tools": "^1.4.2"
"@companion-module/tools": "^1.5.0"
}
}
27 changes: 21 additions & 6 deletions pjlink.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ function stamp() {
return `${d.getMinutes()}:${d.getSeconds()}.${d.getMilliseconds()}`
}


class PJInstance extends InstanceBase {
constructor(internal) {
super(internal)
Expand All @@ -33,6 +32,9 @@ class PJInstance extends InstanceBase {
// When module gets deleted
destroy(restart) {
if (this.socket !== undefined) {
if (this.socket.isConnected()) {
this.socket.end()
}
this.socket.destroy()
delete this.socket
}
Expand Down Expand Up @@ -99,7 +101,10 @@ class PJInstance extends InstanceBase {
this.badPassword = true
this.authOK = false
this.passwordstring = ''
this.socket?.destroy()
if (this.socket?.isConnected()) {
this.socket.end()
this.socket.destroy()
}
delete this.socket
this.restartSocket(15000)
} else {
Expand Down Expand Up @@ -136,7 +141,6 @@ class PJInstance extends InstanceBase {
}

restartSocket(waitTime = 5000) {

if (this.restartTimer) {
clearInterval(this.restartTimer)
delete this.restartTimer
Expand All @@ -152,7 +156,6 @@ class PJInstance extends InstanceBase {
}

init_tcp(cb) {

let receivebuffer = ''
this.passwordstring = ''
let args
Expand All @@ -173,6 +176,9 @@ class PJInstance extends InstanceBase {
}

if (this.socket !== undefined) {
if (this.socket.isConnected()) {
this.socket.end()
}
this.socket.destroy()
delete this.socket
}
Expand Down Expand Up @@ -203,6 +209,9 @@ class PJInstance extends InstanceBase {
}

if (this.socket !== undefined && this.socket.destroy !== undefined) {
if (this.socket.isConnected()) {
this.socket.end()
}
this.socket.destroy()
delete this.socket
}
Expand Down Expand Up @@ -240,6 +249,9 @@ class PJInstance extends InstanceBase {
delete this.socketTimer
}
if (this.socket !== undefined && this.socket.destroy !== undefined) {
if (this.socket.isConnected()) {
this.socket.end()
}
this.socket.destroy()
delete this.socket
}
Expand Down Expand Up @@ -324,7 +336,8 @@ class PJInstance extends InstanceBase {
}
this.log('debug', `PJLINK ERROR: ${errorText}`)
}
} else if (data.match(/^PJLINK*/i)) { // auth password setup
} else if (data.match(/^PJLINK*/i)) {
// auth password setup
this.check_auth(data, cb)
} else {
let cmd = data.slice(0, 6).toUpperCase()
Expand Down Expand Up @@ -567,6 +580,9 @@ class PJInstance extends InstanceBase {
delete this.socketTimer
}
if (this.socket !== undefined && this.socket.destroy !== undefined) {
if (this.socket.isConnected()) {
this.socket.end()
}
this.socket.destroy()
}

Expand Down Expand Up @@ -1161,7 +1177,6 @@ class PJInstance extends InstanceBase {
}

async getProjectorDetails() {

//Query Projector Class
await this.sendCmd('%1CLSS ?')
// await this.sendCmd('%1AVMT ?')
Expand Down
Loading

0 comments on commit 8766624

Please sign in to comment.