dispatcher

package
v0.0.2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 9, 2023 License: Apache-2.0 Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewSession

func NewSession(private authentication.ECDHPrivateKey, vin string) (*session, error)

NewSession creates a new session object that can authorize commands going to the vehicle and authenticate session info arriving from the vehicle.

func SessionInfoRequest

func SessionInfoRequest(domain universal.Domain, publicBytes []byte) *universal.RoutableMessage

SessionInfoRequest returns a RoutableMesasge that initiates a handshake with a vehicle Domain.

Types

type CacheEntry

type CacheEntry struct {
	CreatedAt   time.Time `json:"created_at"`
	Domain      int       `json:"domain"`
	SessionInfo []byte    `json:"data"`
}

CacheEntry contains information that allows a vehicle session to be resumed without a handshake mesasge (SessionInfoRequest).

type Dispatcher

type Dispatcher struct {
	// contains filtered or unexported fields
}

Dispatcher objects send (encrypted) messages to a vehicle and route incoming messages to the appropriate receiver object.

func New

New creates a Dispatcher from a Connector.

func (*Dispatcher) Cache

func (d *Dispatcher) Cache() []CacheEntry

Cache returns a list of CacheEntry objects that contain session state for the authenticated connections to a vehicle's Domains.

func (*Dispatcher) LoadCache

func (d *Dispatcher) LoadCache(entries []CacheEntry) error

LoadCache initializes or overwrites d's sessions. This allows resuming a session with a vehicle without requiring a round trip.

func (*Dispatcher) RequestSessionInfo

func (d *Dispatcher) RequestSessionInfo(ctx context.Context, domain universal.Domain) (protocol.Receiver, error)

RequestSessionInfo sends a handshake request and returns a protocol.Receiver for receiving the response.

func (*Dispatcher) RetryInterval

func (d *Dispatcher) RetryInterval() time.Duration

RetryInterval fetches the transport-layer dependent recommended delay between retry attempts.

func (*Dispatcher) Send

Send a message to a vehicle.

func (*Dispatcher) Start

func (d *Dispatcher) Start(ctx context.Context) error

Start runs d's Listen method in a new goroutine. Returns an error if d does not signal it's ready before ctx expires.

func (*Dispatcher) StartSession

func (d *Dispatcher) StartSession(ctx context.Context, domain universal.Domain) error

StartSession sends a blocking request start an authenticated session with a universal.Domain.

func (*Dispatcher) StartSessions

func (d *Dispatcher) StartSessions(ctx context.Context, domains []universal.Domain) error

StartSessions starts sessions with the provided vehicle domains (or all supported domains, if domains is nil).

If multiple connections fail, only returns the first error.

func (*Dispatcher) Stop

func (d *Dispatcher) Stop()

Stop signals any goroutine running Listen to exit.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL