Documentation
¶
Index ¶
- type Listener
- func (ls *Listener) AddCallback(cb result.Callback) (token.Token, error)
- func (ls *Listener) RemoveCallback(t token.Token) error
- func (ls *Listener) Result() *result.Result
- func (ls *Listener) Start() error
- func (ls *Listener) Stop() error
- func (ls *Listener) WaitForAnyResult(timeout time.Duration) *result.Result
- func (ls *Listener) WaitForNewResult(timeout time.Duration) *result.Result
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 ¶
func New(ub unitybridge.UnityBridge, l *logger.Logger, k *key.Key, cb result.Callback) *Listener
New creates a new Listener instance.
func (*Listener) AddCallback ¶
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 ¶
RemoveCallback removes the callback associated with the likstener key and the given token.
func (*Listener) Start ¶
Start starts the listener. If cb is non nil, it will be called when a new result is available.
func (*Listener) WaitForAnyResult ¶
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 ¶
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.