Documentation ¶
Index ¶
- Constants
- type Manager
- func (m *Manager) Attach(plugin string, handle int64, onConnect func(*connection.Connection) error, ...) (*connection.Connection, error)
- func (m *Manager) Context() context.Context
- func (m *Manager) Detach(plugin string, handle int64) error
- func (m *Manager) GetConnection() *connection.Connection
- func (m *Manager) HTTPWebsocketHandler(rw http.ResponseWriter, req *http.Request)
- func (m *Manager) HandleWebsocketConnect(ctx context.Context, transaction string, rw http.ResponseWriter, ...) error
- func (m *Manager) NewHandle() int64
- func (m *Manager) NumActive() uint64
- func (m *Manager) OnBeforeDisconnect(c *connection.Connection, err error) error
- func (m *Manager) OnConnect(c *connection.Connection) error
- func (m *Manager) OnDisconnect(c *connection.Connection) error
- func (m *Manager) OnError(c *connection.Connection, err error) error
- func (m *Manager) OnText(c *connection.Connection, msg []byte) error
- func (m *Manager) Pipeline(plugin string, id string) *Pipeline
- type Pipeline
- type WebsocketMessage
Constants ¶
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 ¶
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 ¶
Context Returns the Context of the associated manager.
func (*Manager) Detach ¶
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 ¶
NewHandle returns the next available handle id of the accociated manager.
func (*Manager) NumActive ¶
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.
type Pipeline ¶
type Pipeline struct {
// contains filtered or unexported fields
}
Pipeline is a pipeline to forward rtm messages to the mcu.
func (*Pipeline) Close ¶
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) Mode ¶
Mode returns the accociated Pipeline's Mode.
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.