leap

package
v1.12.1 Latest Latest
Warning

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

Go to latest
Published: Mar 14, 2023 License: MIT Imports: 14 Imported by: 0

README

Leap Client

The Leap client for the Go SDK. Documentation can be found here.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Client

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

Client is used to define a Leap client. Please use NewClient to create a new client.

func NewClient

func NewClient(projectId, token string, l Logger) *Client

NewClient is used to create a new client. If the specified logger is nil, the library will not log any data.

func (*Client) AddStateUpdateListener

func (c *Client) AddStateUpdateListener(handler func(types.LeapStateInfo))

AddStateUpdateListener adds a handler to be called when the state changes.

func (*Client) ChannelEventChannel

func (c *Client) ChannelEventChannel() <-chan types.LeapChannelEvent

ChannelEventChannel is used to get a channel that will receive all channel events. The only exception to this is events that are a reply to functions in this package. Those will be returned from the function.

func (*Client) Close

func (c *Client) Close() error

Close closes the connection and all channels for events.

func (*Client) Connect

func (c *Client) Connect() error

Connect is used to connect to the Leap server.

func (*Client) InitEvent

func (c *Client) InitEvent() *types.LeapInitEvent

InitEvent is used to return the init event. Can be nil if it is not sent.

func (*Client) MessageEventChannel

func (c *Client) MessageEventChannel() <-chan types.LeapMessageEvent

MessageEventChannel is used to get a channel that will receive all message events.

func (*Client) State

func (c *Client) State() types.LeapStateInfo

State returns the state of the websocket.

func (*Client) Subscribe

func (c *Client) Subscribe(channelId string) (*types.ChannelPartial, error)

Subscribe subscribes to a channel.

type Logger

type Logger interface {
	// Debug is used to log debug information.
	Debug(message string, metadata map[string]any)

	// Info is used to log information.
	Info(message string, metadata map[string]any)

	// Warn is used to log a warning.
	Warn(message string, metadata map[string]any)

	// Error is used to log an error. Note that the error object can be nil and this can just be error data.
	Error(message string, err error, metadata map[string]any)
}

Logger is used to define the interface for a logger. It is un-opinionated, you will probably want to implement this interface for your logging client. By default, this client does not log.

func NewFmtLogger

func NewFmtLogger() Logger

NewFmtLogger creates a new fmt logger.

type NopLogger

type NopLogger struct{}

NopLogger is used to define a logger that does nothing.

func (NopLogger) Debug

func (NopLogger) Debug(string, map[string]any)

Debug implements Logger.

func (NopLogger) Error

func (NopLogger) Error(string, error, map[string]any)

Error implements Logger.

func (NopLogger) Info

func (NopLogger) Info(string, map[string]any)

Info implements Logger.

func (NopLogger) Warn

func (NopLogger) Warn(string, map[string]any)

Warn implements Logger.

Jump to

Keyboard shortcuts

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