Skip to content

Commit

Permalink
feat: goto command
Browse files Browse the repository at this point in the history
  • Loading branch information
Balte de Wit committed Sep 21, 2019
1 parent e7c47d4 commit bc05045
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 0 deletions.
35 changes: 35 additions & 0 deletions src/commands/goTo.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
import { NamedMessage } from '../message'
import { AbstractCommandNoResponse } from './abstractCommand'

export class GoToCommand extends AbstractCommandNoResponse {
clip?: string
clipId?: number
timecode?: string

constructor (clip?: string, clipId?: number, timecode?: string) {
super()

this.clip = clip
this.clipId = clipId
this.timecode = timecode
}

serialize () {
const res: NamedMessage = {
name: 'goto',
params: {}
}

if (this.clip !== undefined) res.params.clip = this.clip
if (this.clipId !== undefined) res.params.clipId = this.clipId + ''
if (this.timecode !== undefined) res.params.timecode = this.timecode

if (Object.keys(res.params).length === 0) {
throw new Error('GoToCommand needs at least one parameter')
} else if (Object.keys(res.params).length > 1) {
throw new Error('GoToCommand should have at most one parameter')
}

return res
}
}
1 change: 1 addition & 0 deletions src/commands/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ export * from './connect'
export * from './configuration'
export * from './deviceInfo'
export * from './format'
export * from './goTo'
export * from './notify'
export * from './playCommand'
export * from './record'
Expand Down

0 comments on commit bc05045

Please sign in to comment.