-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: refactor the async handlers to be chosen more dynamically
- Loading branch information
Showing
9 changed files
with
102 additions
and
77 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
import { AsynchronousCode } from '../codes' | ||
import { ResponseMessage } from '../message' | ||
|
||
export interface IHandler { | ||
responseCode: AsynchronousCode | ||
eventName: string | ||
|
||
deserialize (msg: ResponseMessage): any | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
export * from './iHandler' | ||
export * from './slotInfo' | ||
export * from './transportInfo' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
import { SlotId, VideoFormat, SlotStatus } from '../enums' | ||
import { ResponseMessage } from '../message' | ||
import { parseIntIfDefined } from '../util' | ||
import { IHandler } from './iHandler' | ||
import { AsynchronousCode } from '../codes' | ||
|
||
export interface SlotInfoChangeResponse { | ||
SlotId: SlotId | ||
Status?: SlotStatus | ||
VolumeName?: string | ||
RecordingTime?: number | ||
VideoFormat?: VideoFormat | ||
} | ||
|
||
export class SlotInfoChange implements IHandler { | ||
responseCode = AsynchronousCode.SlotInfo | ||
eventName = 'notify.transport' | ||
|
||
deserialize (msg: ResponseMessage) { | ||
const res: SlotInfoChangeResponse = { | ||
SlotId: parseInt(msg.Params['slot id'], 10), | ||
Status: msg.Params['status'] as SlotStatus, | ||
VolumeName: msg.Params['volume name'], | ||
RecordingTime: parseIntIfDefined(msg.Params['recording time']), | ||
VideoFormat: msg.Params['video format'] as VideoFormat | ||
} | ||
return res | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
import { TransportStatus, SlotId, VideoFormat } from '../enums' | ||
import { ResponseMessage } from '../message' | ||
import { parseIdOrNone, parseIntIfDefined, parseBool } from '../util' | ||
import { IHandler } from './iHandler' | ||
import { AsynchronousCode } from '../codes' | ||
|
||
export interface TransportInfoChangeResponse { | ||
Status?: TransportStatus | ||
Speed?: number | ||
SlotId?: SlotId | null | ||
ClipId?: number | null | ||
SingleClip?: boolean | ||
DisplayTimecode?: string | ||
Timecode?: string | ||
VideoFormat?: VideoFormat | ||
Loop?: boolean | ||
} | ||
|
||
export class TransportInfoChange implements IHandler { | ||
responseCode = AsynchronousCode.TransportInfo | ||
eventName = 'notify.transport' | ||
|
||
deserialize (msg: ResponseMessage) { | ||
const res: TransportInfoChangeResponse = { | ||
Status: msg.Params['status'] as TransportStatus, | ||
Speed: parseIntIfDefined(msg.Params['speed']), | ||
SlotId: parseIdOrNone(msg.Params['slot id']), | ||
ClipId: parseIdOrNone(msg.Params['clip id']), | ||
SingleClip: parseBool(msg.Params['single clip']), | ||
DisplayTimecode: msg.Params['display timecode'], | ||
Timecode: msg.Params['timecode'], | ||
VideoFormat: msg.Params['video format'] as VideoFormat, | ||
Loop: parseBool(msg.Params['loop']) | ||
} | ||
return res | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters