-
Notifications
You must be signed in to change notification settings - Fork 15
/
emitter.go
29 lines (22 loc) · 1008 Bytes
/
emitter.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
// SPDX-License-Identifier: Apache-2.0
package transport
import (
"context"
)
// OcppVersion represents the version of OCPP that is being used.
type OcppVersion string
const (
OcppVersion16 OcppVersion = "ocpp1.6" // OCPP 1.6
OcppVersion201 OcppVersion = "ocpp2.0.1" // OCPP 2.0.1
)
// Emitter defines the contract for sending messages to the gateway.
type Emitter interface {
// Emit sends a message, destined for a specific charge station which is identified by its
// chargeStationId using a specific ocppVersion, to the gateway.
Emit(ctx context.Context, ocppVersion OcppVersion, chargeStationId string, message *Message) error
}
// EmitterFunc allows a plain function to be used as an Emitter
type EmitterFunc func(ctx context.Context, ocppVersion OcppVersion, chargeStationId string, message *Message) error
func (e EmitterFunc) Emit(ctx context.Context, ocppVersion OcppVersion, chargeStationId string, message *Message) error {
return e(ctx, ocppVersion, chargeStationId, message)
}