listener

package
v0.0.11 Latest Latest
Warning

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

Go to latest
Published: Aug 6, 2024 License: Apache-2.0 Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Listener

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

Listener is a helper class to listen for event results from the Unity Bridge. It allows callers to wait for new results, to get the last result obtained and to register a callback to be called when a new result is available. It is thread safe.

func New

New creates a new Listener instance.

func (*Listener) AddCallback

func (ls *Listener) AddCallback(cb result.Callback) (token.Token, error)

AddCallback adds a callback to be called when a new result is available for this listener key. The returned token can be used to remove the callback later.

func (*Listener) RemoveCallback

func (ls *Listener) RemoveCallback(t token.Token) error

RemoveCallback removes the callback associated with the likstener key and the given token.

func (*Listener) Result

func (ls *Listener) Result() *result.Result

Result returns the current result.

func (*Listener) Start

func (ls *Listener) Start() error

Start starts the listener. If cb is non nil, it will be called when a new result is available.

func (*Listener) Stop

func (ls *Listener) Stop() error

Stop stops the listener.

func (*Listener) WaitForAnyResult

func (ls *Listener) WaitForAnyResult(timeout time.Duration) *result.Result

WaitForAnyResult returns any existing result immediatelly or blocks until a result is available, a timeout happens or the listener is stopped. If result is nil, no result was available (for example, if the listener is closed). If result is non nil, Callers should inspect the result error code and description to check if the result is valid.

func (*Listener) WaitForNewResult

func (ls *Listener) WaitForNewResult(timeout time.Duration) *result.Result

WaitForNewResult blocks until a new result is available, a timeout happens or the listener is stopped. If result is nil, no result was available (for example, if the listener is closed). If result is non nil, Callers should inspect the result error code and description to check if the result is valid.

Jump to

Keyboard shortcuts

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