service

package
v0.14.0 Latest Latest
Warning

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

Go to latest
Published: Mar 22, 2024 License: AGPL-3.0, Apache-2.0 Imports: 26 Imported by: 1

Documentation

Index

Constants

View Source
const (
	ClientMessageJoin      = "join"
	ClientMessageLeave     = "leave"
	ClientMessageRTC       = "rtc"
	ClientMessageHello     = "hello"
	ClientMessageReconnect = "reconnect"
	ClientMessageClose     = "close"
	ClientMessageVAD       = "vad"
)

Variables

This section is empty.

Functions

func NewPackedClientMessage added in v0.6.10

func NewPackedClientMessage(msgType string, data interface{}) ([]byte, error)

Types

type APIConfig

type APIConfig struct {
	HTTP     api.Config     `toml:"http"`
	Security SecurityConfig `toml:"security"`
}

func (APIConfig) IsValid

func (c APIConfig) IsValid() error

type Client

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

func NewClient

func NewClient(cfg ClientConfig, opts ...ClientOption) (*Client, error)

func (*Client) Close

func (c *Client) Close() error

func (*Client) Connect

func (c *Client) Connect() error

func (*Client) ErrorCh

func (c *Client) ErrorCh() <-chan error

func (*Client) GetVersionInfo added in v0.8.0

func (c *Client) GetVersionInfo() (VersionInfo, error)

func (*Client) ReceiveCh

func (c *Client) ReceiveCh() <-chan ClientMessage

func (*Client) Register

func (c *Client) Register(clientID string, authKey string) error

func (*Client) Send

func (c *Client) Send(msg ClientMessage) error

func (*Client) Unregister

func (c *Client) Unregister(clientID string) error

type ClientConfig

type ClientConfig struct {
	ClientID          string
	AuthKey           string
	URL               string
	ReconnectInterval time.Duration
	// contains filtered or unexported fields
}

func (*ClientConfig) Parse

func (c *ClientConfig) Parse() error

type ClientMessage

type ClientMessage struct {
	Type string      `msgpack:"type"`
	Data interface{} `msgpack:"data,omitempty"`
}

func NewClientMessage

func NewClientMessage(msgType string, data interface{}) *ClientMessage

func (*ClientMessage) DecodeMsgpack

func (cm *ClientMessage) DecodeMsgpack(dec *msgpack.Decoder) error

func (*ClientMessage) EncodeMsgpack

func (cm *ClientMessage) EncodeMsgpack(enc *msgpack.Encoder) error

func (*ClientMessage) Pack

func (cm *ClientMessage) Pack() ([]byte, error)

func (*ClientMessage) Unpack

func (cm *ClientMessage) Unpack(data []byte) error

type ClientOption

type ClientOption func(c *Client) error

func WithClientReconnectCb

func WithClientReconnectCb(cb ClientReconnectCb) ClientOption

WithClientReconnectCb lets the caller set an optional callback to be called prior to performing a WebSocket reconnection.

func WithDialFunc added in v0.5.0

func WithDialFunc(dialFn DialContextFn) ClientOption

WithDialFunc lets the caller set an optional dialing function to setup the HTTP/WebSocket connections used by the client.

type ClientReconnectCb

type ClientReconnectCb func(c *Client, attempt int) error

type Config

type Config struct {
	API    APIConfig
	RTC    rtc.ServerConfig
	Store  StoreConfig
	Logger logger.Config
}

func (Config) IsValid

func (c Config) IsValid() error

func (*Config) SetDefaults

func (c *Config) SetDefaults()

type DialContextFn added in v0.5.0

type DialContextFn func(ctx context.Context, network, addr string) (net.Conn, error)

type SecurityConfig

type SecurityConfig struct {
	// Whether or not to enable admin API access.
	EnableAdmin bool `toml:"enable_admin"`
	// The secret key used to authenticate admin requests.
	AdminSecretKey string `toml:"admin_secret_key"`
	// Whether or not to allow clients to self-register.
	AllowSelfRegistration bool                    `toml:"allow_self_registration"`
	SessionCache          auth.SessionCacheConfig `toml:"session_cache"`
}

func (SecurityConfig) IsValid

func (c SecurityConfig) IsValid() error

type Service

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

func New

func New(cfg Config) (*Service, error)

func (*Service) Start

func (s *Service) Start() error

func (*Service) Stop

func (s *Service) Stop() error

type StoreConfig

type StoreConfig struct {
	DataSource string `toml:"data_source"`
}

func (StoreConfig) IsValid

func (c StoreConfig) IsValid() error

type VersionInfo added in v0.8.0

type VersionInfo struct {
	BuildDate    string `json:"buildDate"`
	BuildVersion string `json:"buildVersion"`
	BuildHash    string `json:"buildHash"`
	GoVersion    string `json:"goVersion"`
}

Directories

Path Synopsis
rtc
vad

Jump to

Keyboard shortcuts

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