Documentation ¶
Index ¶
- Constants
- Variables
- func CreateNamedGroupChannelID(id string, m *Manager) (string, error)
- func MustRegister(reg prometheus.Registerer, cs ...prometheus.Collector)
- func NewManagerCollector(manager *Manager) prometheus.Collector
- type Channel
- func (c *Channel) Add(id string, conn *connection.Connection) error
- func (c *Channel) CanBeCleanedUp() bool
- func (c *Channel) Cleanup() bool
- func (c *Channel) Connections() ([]string, []*connection.Connection)
- func (c *Channel) Forward(source string, target string, conn *connection.Connection, ...) error
- func (c *Channel) Get(id string) (*connection.Connection, bool)
- func (c *Channel) Pipeline() Pipeline
- func (c *Channel) Remove(id string) error
- func (c *Channel) Size() int
- type ChannelConfig
- type ChannelOp
- type Manager
- func (m *Manager) Connect(ctx context.Context, userID string, auth *api.AdminAuthToken) (string, error)
- func (m *Manager) Context() context.Context
- func (m *Manager) HTTPWebsocketHandler(rw http.ResponseWriter, req *http.Request)
- func (m *Manager) HandleWebsocketConnect(ctx context.Context, key string, rw http.ResponseWriter, req *http.Request) error
- func (m *Manager) LookupConnectionsByID(id string) ([]*connection.Connection, bool)
- func (m *Manager) MakeHTTPConnectHandler(router *mux.Router, websocketRouteIdentifier string) http.Handler
- func (m *Manager) MakeHTTPTURNHandler(router *mux.Router) http.Handler
- 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) OnServerStatus(newServerStatus *api.ServerStatus) error
- func (m *Manager) OnText(c *connection.Connection, msg []byte) error
- func (m *Manager) Pipeline(scope string, id string) Pipeline
- type Pipeline
Constants ¶
const ( ChannelPrefixStandard = "*" ChannelPrefixNamedGroup = "@" )
Channel ID prefixes
Variables ¶
var ChannelDefaultConfig = &ChannelConfig{}
ChannelDefaultConfig holds a Channel's default extra configuration.
Functions ¶
func CreateNamedGroupChannelID ¶
CreateNamedGroupChannelID creates consistent channel IDs from input parameters.
func MustRegister ¶
func MustRegister(reg prometheus.Registerer, cs ...prometheus.Collector)
MustRegister registers all rtm metrics with the provided registerer and panics upon the first registration that causes an error.
func NewManagerCollector ¶
func NewManagerCollector(manager *Manager) prometheus.Collector
NewManagerCollector return as a collector that exports metrics of the provided Manager,
Types ¶
type Channel ¶
Channel binds connections together.
func CreateKnownChannel ¶
func CreateKnownChannel(id string, m *Manager, config *ChannelConfig) *Channel
CreateKnownChannel creates a new channel with known id.
func CreateRandomChannel ¶
func CreateRandomChannel(m *Manager, config *ChannelConfig) *Channel
CreateRandomChannel creates a new channel with random id.
func NewChannel ¶
func NewChannel(id string, m *Manager, logger logrus.FieldLogger, config *ChannelConfig) *Channel
NewChannel initializes a new channel with id.
func (*Channel) Add ¶
func (c *Channel) Add(id string, conn *connection.Connection) error
Add adds the provided connection to the channel identified by id.
func (*Channel) CanBeCleanedUp ¶
CanBeCleanedUp up returns true if the channel can be cleaned up.
func (*Channel) Cleanup ¶
Cleanup closes the associated channels resources and marks the channel closed.
func (*Channel) Connections ¶
func (c *Channel) Connections() ([]string, []*connection.Connection)
Connections returns a array the currenct connection ids and an array of the current connections of this channel.
func (*Channel) Forward ¶
func (c *Channel) Forward(source string, target string, conn *connection.Connection, msg *api.RTMTypeWebRTC) error
Forward takes care of sending the provided message to the channels assigned target.
func (*Channel) Get ¶
func (c *Channel) Get(id string) (*connection.Connection, bool)
Get retrieves the connection identified by the provided id.
func (*Channel) Pipeline ¶
Pipeline returns the attached Channel's Pipeline.
func (*Channel) Remove ¶
Remove removes the connection identified by the provided id.
type ChannelConfig ¶
type ChannelConfig struct { Group string Replace func(channel *Channel, cid string, oldConn *connection.Connection, newConn *connection.Connection) AfterAddOrRemove func(channel *Channel, op ChannelOp, cid string) AfterReset func(channel *Channel) }
ChannelConfig adds extra configuration for a Channel.
type Manager ¶
type Manager struct {
// contains filtered or unexported fields
}
Manager handles RTM connect state.
func NewManager ¶
func NewManager(ctx context.Context, id string, insecure bool, requiredScopes []string, pipelineForcedPatternString string, logger logrus.FieldLogger, mcum *mcu.Manager, adminm *admin.Manager, guestm *guest.Manager, oidcp *kcoidc.Provider, turnsrv turn.Server) *Manager
NewManager creates a new Manager with an id.
func (*Manager) Connect ¶
func (m *Manager) Connect(ctx context.Context, userID string, auth *api.AdminAuthToken) (string, error)
Connect adds a new connect entry to the managers table with random key.
func (*Manager) Context ¶
Context Returns the Context of the associated manager.
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, key string, rw http.ResponseWriter, req *http.Request) error
HandleWebsocketConnect checks the presence of the key in cache and starts the websocket connection in a new go routine. Returns with nil when the websocket connection was successfuly started, otherwise with error.
func (*Manager) LookupConnectionsByID ¶
func (m *Manager) LookupConnectionsByID(id string) ([]*connection.Connection, bool)
LookupConnectionsByID returns a copy slice of the active connections for the user accociated with the provided ID.
func (*Manager) MakeHTTPConnectHandler ¶
func (m *Manager) MakeHTTPConnectHandler(router *mux.Router, websocketRouteIdentifier string) http.Handler
MakeHTTPConnectHandler createss the HTTP handler for rtm.connect.
func (*Manager) MakeHTTPTURNHandler ¶
MakeHTTPTURNHandler creates the HTTP handler for rtm.turn.
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) OnServerStatus ¶
func (m *Manager) OnServerStatus(newServerStatus *api.ServerStatus) error
OnServerStatus is called, when the associated server status changes any of its pre defined status settings.
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.