Commit | Line | Data |
---|---|---|
8114d10e | 1 | import { JsonType } from '../../../types/JsonType'; |
33cea517 | 2 | import { |
32de5a57 | 3 | ProcedureName, |
33cea517 JB |
4 | ProtocolRequestHandler, |
5 | ProtocolVersion, | |
32de5a57 LM |
6 | ResponsePayload, |
7 | ResponseStatus, | |
33cea517 | 8 | } from '../../../types/UIProtocol'; |
fe94fce0 | 9 | import { AbstractUIServer } from '../AbstractUIServer'; |
4198ad5c | 10 | import AbstractUIService from './AbstractUIService'; |
4198ad5c | 11 | |
f16356b9 | 12 | export default class UIService001 extends AbstractUIService { |
fe94fce0 | 13 | constructor(uiServer: AbstractUIServer) { |
33cea517 | 14 | super(uiServer, ProtocolVersion['0.0.1']); |
e7aeea18 | 15 | this.messageHandlers.set( |
32de5a57 | 16 | ProcedureName.START_TRANSACTION, |
e7aeea18 JB |
17 | this.handleStartTransaction.bind(this) as ProtocolRequestHandler |
18 | ); | |
19 | this.messageHandlers.set( | |
32de5a57 | 20 | ProcedureName.STOP_TRANSACTION, |
e7aeea18 JB |
21 | this.handleStopTransaction.bind(this) as ProtocolRequestHandler |
22 | ); | |
4198ad5c JB |
23 | } |
24 | ||
32de5a57 LM |
25 | private handleStartTransaction(payload: JsonType): ResponsePayload { |
26 | this.workerBroadcastChannel.postMessage([ProcedureName.START_TRANSACTION, payload]); | |
27 | return { status: ResponseStatus.SUCCESS }; | |
28 | } | |
29 | ||
30 | private handleStopTransaction(payload: JsonType): ResponsePayload { | |
31 | this.workerBroadcastChannel.postMessage([ProcedureName.STOP_TRANSACTION, payload]); | |
32 | return { status: ResponseStatus.SUCCESS }; | |
33 | } | |
4198ad5c | 34 | } |