self

package
v0.0.0-...-ee4a2e9 Latest Latest
Warning

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

Go to latest
Published: Aug 25, 2017 License: Apache-2.0 Imports: 7 Imported by: 0

Documentation

Overview

Package self lets you connect to a self instance via the WS API. To run a self instance, see https://github.com/watson-intu/self, or https://github.com/michaeldye/self-docker-builder

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DummyFilterFalse

func DummyFilterFalse(Thing) bool

DummyFilterFalse always returns false

func DummyFilterTrue

func DummyFilterTrue(Thing) bool

DummyFilterTrue always returns true

func HasText

func HasText(thing Thing) bool

HasText returns true if the things text is non empty.

func PrintThingHandler

func PrintThingHandler(thing Thing)

PrintThingHandler just prints the thing

func PrintThingText

func PrintThingText(thing Thing)

PrintThingText prints only the text of the thing.

func PrintThingType

func PrintThingType(thing Thing)

PrintThingType prints only the Type of the thing.

Types

type Conn

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

Conn is a ws conn + metadata

func Init

func Init(host string) (conn *Conn, err error)

Init the connection

func (*Conn) Pub

func (conn *Conn) Pub(target Target, data msgData)

Pub publishes a message to a topic

func (*Conn) Reg

func (conn *Conn) Reg(name string, handlerFunc ThingHandlerFunc)

Reg registers a function to the connection

func (*Conn) Sub

func (conn *Conn) Sub(targets []Target)

Sub subscribes to a topic

func (*Conn) Unreg

func (conn *Conn) Unreg(name string)

Unreg removes a handler from the connection

func (*Conn) Unsub

func (conn *Conn) Unsub(targets []Target)

Unsub unsubscribes from a topic

type Target

type Target string

Target is a target that can be subscribed to

const (
	TargetBlackboard       Target = "blackboard"
	TargetAgentSociety     Target = "agent-society"
	TargetBlackboardStream Target = "blackboard-stream"
	TargetGestureManager   Target = "gesture-manager"
	TargetSensorManager    Target = "sensor-manager"
	TargetModels           Target = "sensors"
)

Targets

type Thing

type Thing struct {
	GUID           string  `json:"GUID_"`
	Type           string  `json:"Type_"`
	Children       []Thing `json:"m_Children"`
	Confidence     float64 `json:"m_Confidence"`
	CreateTime     float64 `json:"m_CreateTime"`
	Info           string  `json:"m_Info"`
	Name           string  `json:"m_Name"`
	ProxyID        string  `json:"m_ProxyID"`
	State          string  `json:"m_State"`
	Threshold      float64 `json:"m_Threshold"`
	ClassifyIntent bool    `json:"m_ClassifyIntent"`
	Language       string  `json:"m_Language"`
	LocalDialog    bool    `json:"m_LocalDialog"`
	Text           string  `json:"m_Text"`
	ECategory      int     `json:"m_eCategory"`
	FImportance    int     `json:"m_fImportance"`
	FLifeSpan      int     `json:"m_fLifeSpan"`
}

Thing is a thing

type ThingFilter

type ThingFilter func(Thing) bool

ThingFilter desides if a Thing needs to be handled.

func And

func And(filters []ThingFilter) ThingFilter

And returns a filter which returns true if none of the filters return false.

func MakeFilterNth

func MakeFilterNth(n int) ThingFilter

MakeFilterNth returns a filter that returns true every n times.

func MakeThingTypeFilter

func MakeThingTypeFilter(typeName string) ThingFilter

MakeThingTypeFilter returns a Thing which returns true if the things type matches the given typeName

func Not

func Not(filter ThingFilter) ThingFilter

Not returns a filter which inverts the provided filter.

func Or

func Or(filters []ThingFilter) ThingFilter

Or returns a filter which returns true if any of the filters return true.

func Xor

func Xor(filter1, filter2 ThingFilter) ThingFilter

Xor returns a filter which returns true if filter 1 xor filter2 return true.

type ThingHandlerFunc

type ThingHandlerFunc func(Thing)

ThingHandlerFunc handels an incoming Thing

func MakeFilteredHandler

func MakeFilteredHandler(filter func(Thing) bool, handle ThingHandlerFunc) ThingHandlerFunc

MakeFilteredHandler makes a MsgHandlerFunc that only called the given MsgHandlerFunc is filter returns true.

Jump to

Keyboard shortcuts

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