-
Notifications
You must be signed in to change notification settings - Fork 63
/
OutgoingOcppEndpoint.scala
49 lines (43 loc) · 1.67 KB
/
OutgoingOcppEndpoint.scala
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
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
package com.thenewmotion.ocpp
package json.api
import scala.language.higherKinds
import scala.concurrent.Future
import messages._
/**
* Generic interface of an outgoing OCPP connection endpoint as it appears to the
* library user:
*
* * The send method should be called to send outgoing requests
* * The close method should be called to close the connection
*
* @tparam OUTREQ The type of outgoing requests (either ChargePointReq or CentralSystemReq)
* @tparam INRES The type of incoming responses (either ChargePointRes or CentralSystemRes)
* @tparam OUTREQRES Typeclass relating outgoing request types to incoming response types
*/
trait OutgoingOcppEndpoint[
OUTREQ <: Request,
INRES <: Response,
OUTREQRES[_ <: OUTREQ, _ <: INRES] <: ReqRes[_, _]
] {
/**
* Send a request to the party at the other side of this connection
*
* @param req The request to send
* @param reqRes Evidence of the request-response relationship of the REQ and RES types
* @tparam REQ The type of request (e.g. BootNotificationReq, ResetReq, ...)
* @tparam RES The type of response (e.g. BootNotificationRes, ResetRes, ...)
* @return A future that will be completed with the response from the other
* side. If the other side fails to respond, the future will be failed.
*/
def send[REQ <: OUTREQ, RES <: INRES](req: REQ)(implicit reqRes: OUTREQRES[REQ, RES]): Future[RES]
/**
* Close the connection
*
* This method is asynchronous: once the connection has been closed, the future is completed.
*/
def close(): Future[Unit]
/**
* @return A future that is completed once the connection is closed
*/
def onClose: Future[Unit]
}