Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type CmdSendFunc ¶
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
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 ¶
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 (*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 ¶
ListenAndServe listen on local addresses and accept connections from extensions