3 ProtocolRequestHandler
,
8 } from
'../../../types/UIProtocol';
10 BroadcastChannelProcedureName
,
11 BroadcastChannelRequestPayload
,
12 } from
'../../../types/WorkerBroadcastChannel';
13 import { AbstractUIServer
} from
'../AbstractUIServer';
14 import AbstractUIService from
'./AbstractUIService';
16 export default class UIService001
extends AbstractUIService
{
17 constructor(uiServer
: AbstractUIServer
) {
18 super(uiServer
, ProtocolVersion
['0.0.1']);
19 this.messageHandlers
.set(
20 ProcedureName
.START_TRANSACTION
,
21 this.handleStartTransaction
.bind(this) as ProtocolRequestHandler
23 this.messageHandlers
.set(
24 ProcedureName
.STOP_TRANSACTION
,
25 this.handleStopTransaction
.bind(this) as ProtocolRequestHandler
27 this.messageHandlers
.set(
28 ProcedureName
.START_CHARGING_STATION
,
29 this.handleStartChargingStation
.bind(this) as ProtocolRequestHandler
31 this.messageHandlers
.set(
32 ProcedureName
.STOP_CHARGING_STATION
,
33 this.handleStopChargingStation
.bind(this) as ProtocolRequestHandler
37 private handleStartTransaction(uuid
: string, payload
: RequestPayload
): ResponsePayload
{
38 this.workerBroadcastChannel
.sendRequest([
40 BroadcastChannelProcedureName
.START_TRANSACTION
,
41 payload
as BroadcastChannelRequestPayload
,
43 return { status: ResponseStatus
.SUCCESS
};
46 private handleStopTransaction(uuid
: string, payload
: RequestPayload
): ResponsePayload
{
47 this.workerBroadcastChannel
.sendRequest([
49 BroadcastChannelProcedureName
.STOP_TRANSACTION
,
50 payload
as BroadcastChannelRequestPayload
,
52 return { status: ResponseStatus
.SUCCESS
};
55 private handleStartChargingStation(uuid
: string, payload
: RequestPayload
): ResponsePayload
{
56 this.workerBroadcastChannel
.sendRequest([
58 BroadcastChannelProcedureName
.START_CHARGING_STATION
,
59 payload
as BroadcastChannelRequestPayload
,
61 return { status: ResponseStatus
.SUCCESS
};
64 private handleStopChargingStation(uuid
: string, payload
: RequestPayload
): ResponsePayload
{
65 this.workerBroadcastChannel
.sendRequest([
67 BroadcastChannelProcedureName
.STOP_CHARGING_STATION
,
68 payload
as BroadcastChannelRequestPayload
,
70 return { status: ResponseStatus
.SUCCESS
};