mcu

package
v1.2.1-0...-521e7c1 Latest Latest
Warning

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

Go to latest
Published: Mar 4, 2021 License: AGPL-3.0-only Imports: 16 Imported by: 4

Documentation

Index

Constants

View Source
const (
	PluginIDKWMRTMChannel = "kwm.rtm.channel"
)

Known plugin identifiers.

Variables

This section is empty.

Functions

This section is empty.

Types

type Manager

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

Manager handles RTM connect state.

func NewManager

func NewManager(ctx context.Context, id string, logger logrus.FieldLogger) *Manager

NewManager creates a new Manager with an id.

func (*Manager) Attach

func (m *Manager) Attach(plugin string, handle int64, onConnect func(*connection.Connection) error, onText func(*connection.Connection, []byte) error) (*connection.Connection, error)

Attach sends the attach message with the provided parameters.

func (*Manager) Context

func (m *Manager) Context() context.Context

Context Returns the Context of the associated manager.

func (*Manager) Detach

func (m *Manager) Detach(plugin string, handle int64) error

Detach sends the detach message with the provided parameters.

func (*Manager) GetConnection

func (m *Manager) GetConnection() *connection.Connection

GetConnection returns a connection from the accociated connections table

func (*Manager) HTTPWebsocketHandler

func (m *Manager) HTTPWebsocketHandler(rw http.ResponseWriter, req *http.Request)

HTTPWebsocketHandler implements the HTTP handler for websocket requests.

func (*Manager) HandleWebsocketConnect

func (m *Manager) HandleWebsocketConnect(ctx context.Context, transaction string, rw http.ResponseWriter, req *http.Request) error

HandleWebsocketConnect checks the presence of the key in cache and returns a new connection if key is found.

func (*Manager) NewHandle

func (m *Manager) NewHandle() int64

NewHandle returns the next available handle id of the accociated manager.

func (*Manager) NumActive

func (m *Manager) NumActive() uint64

NumActive returns the number of the currently active connections at the accociated manager.

func (*Manager) OnBeforeDisconnect

func (m *Manager) OnBeforeDisconnect(c *connection.Connection, err error) error

OnBeforeDisconnect is called before a connection is closed. An indication why the connection will be closed is provided with the passed error.

func (*Manager) OnConnect

func (m *Manager) OnConnect(c *connection.Connection) error

OnConnect is called for new connections.

func (*Manager) OnDisconnect

func (m *Manager) OnDisconnect(c *connection.Connection) error

OnDisconnect is called after a connection has closed.

func (*Manager) OnError

func (m *Manager) OnError(c *connection.Connection, err error) error

OnError is called, when the provided connection has encountered an error. The provided error is the error encountered. Any return value other than nil, will result in a close of the connection.

func (*Manager) OnText

func (m *Manager) OnText(c *connection.Connection, msg []byte) error

OnText is called when the provided connection received a text message. The message payload is provided as []byte in the msg parameter.

func (*Manager) Pipeline

func (m *Manager) Pipeline(plugin string, id string) *Pipeline

Pipeline creates a Pipeline with the accociated manager and the provided properties.

type Pipeline

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

Pipeline is a pipeline to forward rtm messages to the mcu.

func (*Pipeline) Close

func (p *Pipeline) Close() error

Close implements the rtm.Pipeline interface.

func (*Pipeline) Connect

func (p *Pipeline) Connect(onConnect func() error, onText func([]byte) error, onReset func(err error) error) error

Connect sends the attach message with the provided parameters.

func (*Pipeline) ID

func (p *Pipeline) ID() string

ID returns the accociated Pipeline's ID.

func (*Pipeline) Mode

func (p *Pipeline) Mode() string

Mode returns the accociated Pipeline's Mode.

func (*Pipeline) Send

func (p *Pipeline) Send(msg interface{}) error

Send implements the rtm.Pipeline interface.

type WebsocketMessage

type WebsocketMessage struct {
	Type        string `json:"type"`
	Transaction string `json:"transaction"`
	Plugin      string `json:"plugin"`
	Handle      int64  `json:"handle_id"`
}

WebsocketMessage is the container for basic mcu websocket messages.

func (*WebsocketMessage) TransactionID

func (m *WebsocketMessage) TransactionID() string

TransactionID returns the transaction ID of the accociated message.

Jump to

Keyboard shortcuts

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