server

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Nov 1, 2020 License: Apache-2.0 Imports: 24 Imported by: 2

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type CmdSendFunc

type CmdSendFunc func(cmd *arhatgopb.Cmd) (*arhatgopb.Msg, error)

Stateful command send func, used to send command to and receive correspond message from the connected extension

type ExtensionContext

type ExtensionContext struct {
	Context context.Context
	Name    string
	SendCmd CmdSendFunc
	// contains filtered or unexported fields
}

ExtensionContext of one extension connection

func NewExtensionContext

func NewExtensionContext(parent context.Context, name string, sendCmd CmdSendFunc) *ExtensionContext

func (*ExtensionContext) Close

func (c *ExtensionContext) Close()

Close extension connection

type ExtensionHandleFunc

type ExtensionHandleFunc func(c *ExtensionContext)

Handle func for your own business logic

type ExtensionHandleFuncFactory

type ExtensionHandleFuncFactory func(extensionName string) (ExtensionHandleFunc, OutOfBandMsgHandleFunc)

Func factory to create extension specific handle func

type ExtensionManager

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

func NewExtensionManager

func NewExtensionManager(
	ctx context.Context,
	logger log.Interface,
	handleFuncFactory ExtensionHandleFuncFactory,
) *ExtensionManager

type OutOfBandMsgHandleFunc

type OutOfBandMsgHandleFunc func(msg *arhatgopb.Msg)

Handle message received from extension without previous command request, all messages passed to this function belongs to one extension

usually instance of this function type is used to handle extension events

e.g. lights turned off manually and detected by the extension

type Server

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

func NewServer

func NewServer(
	ctx context.Context,
	logger log.Interface,
	listenURLs map[string]*tls.Config,
) (*Server, error)

func (*Server) Handle

func (s *Server) Handle(kind arhatgopb.ExtensionType, handleFactory ExtensionHandleFuncFactory, extensions ...string)

Handle extension session with handleFunc, you can specify optional extension names (`extensions`) to restrict the handleFunc to these extensions, if no extension name specified, this handleFunc will override all existing handleFunc for extensions with this kind

func (*Server) ListenAndServe

func (s *Server) ListenAndServe() error

ListenAndServe listen on local addresses and accept connections from extensions

Jump to

Keyboard shortcuts

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