relay

package
v0.0.0-...-bb3eb04 Latest Latest
Warning

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

Go to latest
Published: Jan 10, 2021 License: MIT Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrUnsupportedCommandResponseReceived is returned if the matched up response isn't a command response type
	ErrUnsupportedCommandResponseReceived = errors.New("unsupported command response received")
	// ErrCommandTimeout is returned if the command isn't received in time
	ErrCommandTimeout = errors.New("command request timed out")
	// ErrRequestMissing is returned if the targetted request isn't pending
	ErrRequestMissing = errors.New("request missing")
	// ErrContextTimeout is returned if the command context times out
	ErrContextTimeout = errors.New("context timed out")
	// ErrCommandFailed is returned if we received a proper response but the far end couldn't process it
	ErrCommandFailed = errors.New("command failed")
)
View Source
var (
	// ErrAgentNotFound is returned if the Google Assistant requested an action for a valid user who is not
	// registered with the system at the moment.
	ErrAgentNotFound = errors.New("agent not found")
)
View Source
var (
	// ErrNoAgentRegistered is returned when a message is received on a stream which has not registered an agent.
	ErrNoAgentRegistered = status.New(codes.InvalidArgument, "no agent registered")
)

Functions

This section is empty.

Types

type API

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

API holds the implementation of the Google Home Service gRPC API

func NewAPI

func NewAPI(logger *zap.Logger, ps *ProviderService, as *action.Service) *API

NewAPI creates a new instance of the API

func (*API) StateSync

StateSync contains the bidirectional stream of requests coming in from a connected client.

type ProviderService

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

ProviderService satisfies the Google Smart Home Action Provider contract. This is called by the Google Assistant when users trigger requests against the HomeGraph. This maintains a map of the supported agent IDs and their registered handlers. Any request received that does not have a registered agent ID will fail.

func NewProviderService

func NewProviderService(logger *zap.Logger) *ProviderService

NewProviderService creates a new intent-handling ProviderService to register with the Google Assistant handling framework.

func (*ProviderService) Disconnect

func (s *ProviderService) Disconnect(ctx context.Context, agentID string) error

Disconnect processes the Google Assistant request to remove updates from the specified agent ID.

func (*ProviderService) Execute

Execute processes the Google Assistant request to change the state of the specified devices for the specified agent.

func (*ProviderService) Query

Query processes the Google Assistent request for a state refresh for the specified devices for the specified agent.

func (*ProviderService) RegisterProvider

func (s *ProviderService) RegisterProvider(agentID string, provider action.Provider)

RegisterProvider adds a new agent ID to the set being handled.

func (*ProviderService) Sync

func (s *ProviderService) Sync(ctx context.Context, agentID string) (*action.SyncResponse, error)

Sync processes the Google Assistent request to retrieve the set of devices for the specified agent ID.

func (*ProviderService) UnregisterProvider

func (s *ProviderService) UnregisterProvider(agentID string)

UnregisterProvider removes the registered agent ID from the set of handled providers.

type RemoteProvider

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

RemoteProvider implements a Google Assistent provider that relays requests over a GoogleHomeService streaming RPC.

func NewRemoteProvider

func NewRemoteProvider(logger *zap.Logger, agentID string, stream googlehome.GoogleHomeService_StateSyncServer) *RemoteProvider

NewRemoteProvider creates a new provider backed by a GoogleHomeService streaming RPC.

func (*RemoteProvider) Disconnect

func (m *RemoteProvider) Disconnect(context.Context, string) error

Disconnect removes this agent ID provider.

func (*RemoteProvider) Execute

Execute makes the specified devices change state.

func (*RemoteProvider) Query

Query retrieves the requested device data

func (*RemoteProvider) Sync

Sync returns the set of known devices.

Jump to

Keyboard shortcuts

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