internal

package
v0.0.10 Latest Latest
Warning

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

Go to latest
Published: Jul 20, 2024 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type BaseModule

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

BaseModule is a base implementation of the module.Module interface. It takes care of handling the connection status of the module and provides default implementations for all interface methods.

Module implementations can simply embed this or they can provide custom logic for each method (just be sure to always call the base implementation).

func NewBaseModule

func NewBaseModule(ub unitybridge.UnityBridge, l *logger.Logger,
	name string, k *key.Key, cb result.Callback,
	deps ...module.Module) *BaseModule

NewBaseModule creates a new BaseModule instance with the given name and that will listen for results with the given key. The given callback, if not nil, will be called whenever a new result is received.

func (*BaseModule) Connected

func (g *BaseModule) Connected() bool

Connected returns true if the module is connected, false otherwise.

func (*BaseModule) Logger

func (g *BaseModule) Logger() *logger.Logger

Logger returns the Logger instance used by the module.

func (*BaseModule) Start

func (g *BaseModule) Start() error

Start starts the module by starting the connection result listener.

func (*BaseModule) Stop

func (g *BaseModule) Stop() error

Stop stops the module by stopping the connection result listener.

func (*BaseModule) String

func (g *BaseModule) String() string

String returns the module name.

func (*BaseModule) UB

UB returns the UnityBridge instance used by the module.

func (*BaseModule) WaitForConnection

func (g *BaseModule) WaitForConnection(timeout time.Duration) bool

WaitForConnection returns the current connection status, if one is available or waits for a new one for the given timeout period. It returns true if the module is connected, false otherwise (including if the timeout period is reached or an error happens).

Jump to

Keyboard shortcuts

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