Documentation
¶
Index ¶
- Constants
- func BusSubjectTrigger(prefix, suffix string) string
- func NewDataError(code, message string) error
- type Broadcaster
- type BusManager
- type BusTrigger
- type ByPrioAndStamp
- type ChannellingAPI
- type ChannellingAPIConsumer
- type Client
- type ClientStats
- type Codec
- type Config
- type Connection
- type ConnectionCounter
- type ConnectionHandler
- type Contact
- type ContactManager
- type Context
- type DataAlive
- type DataAnswer
- type DataAuthentication
- type DataAutoCall
- type DataBye
- type DataCandidate
- type DataChat
- type DataChatMessage
- type DataChatStatus
- type DataConference
- type DataContactRequest
- type DataError
- type DataFileInfo
- type DataGeolocation
- type DataHello
- type DataIncoming
- type DataOffer
- type DataOutgoing
- type DataRoom
- type DataRoomCredentials
- type DataSelf
- type DataSession
- type DataSessions
- type DataSessionsRequest
- type DataSink
- type DataSinkOutgoing
- type DataStatus
- type DataTurn
- type DataUser
- type DataWelcome
- type Hub
- type HubStat
- type Image
- type ImageCache
- type IncomingDecoder
- type OutgoingEncoder
- type Pipeline
- func (pipeline *Pipeline) Add(msg *DataSinkOutgoing) *Pipeline
- func (pipeline *Pipeline) Attach(sink Sink) error
- func (pipeline *Pipeline) Close()
- func (pipeline *Pipeline) Expired() bool
- func (pipeline *Pipeline) FlushOutgoing(hub Hub, client *Client, to string, outgoing *DataOutgoing) bool
- func (pipeline *Pipeline) FromSession() *Session
- func (pipeline *Pipeline) GetID() string
- func (pipeline *Pipeline) Index() uint64
- func (pipeline *Pipeline) JSONFeed(since, limit int) ([]byte, error)
- func (pipeline *Pipeline) Refresh(duration time.Duration)
- func (pipeline *Pipeline) Send(b buffercache.Buffer)
- func (pipeline *Pipeline) ToSession() *Session
- type PipelineFeedLine
- type PipelineManager
- type RoomManager
- type RoomStats
- type RoomStatusManager
- type RoomWorker
- type Sender
- type Session
- func (s *Session) AddSubscriber(session *Session)
- func (s *Session) Authenticate(realm string, st *SessionToken, userid string) error
- func (s *Session) Authorize(realm string, st *SessionToken) (string, error)
- func (s *Session) Broadcast(m interface{})
- func (s *Session) BroadcastStatus()
- func (s *Session) Close()
- func (s *Session) Data() *DataSession
- func (s *Session) DecodeAttestation(token string) (string, error)
- func (s *Session) JoinRoom(roomName, roomType string, credentials *DataRoomCredentials, sender Sender) (*DataRoom, error)
- func (s *Session) LeaveRoom()
- func (s *Session) NewAttestation()
- func (s *Session) RemoveSubscriber(id string)
- func (s *Session) Replace(oldSession *Session)
- func (s *Session) SetUseridFake(userid string)
- func (s *Session) Subscribe(session *Session)
- func (s *Session) Token() *SessionToken
- func (s *Session) Unicast(to string, m interface{}, pipeline *Pipeline)
- func (s *Session) Unsubscribe(id string)
- func (s *Session) Update(update *SessionUpdate) uint64
- func (s *Session) UpdateAttestation() (string, error)
- func (s *Session) Userid() (userid string)
- type SessionAttestation
- type SessionCreateRequest
- type SessionCreator
- type SessionEncoder
- type SessionManager
- type SessionStore
- type SessionToken
- type SessionUpdate
- type SessionValidator
- type Sink
- type StatsCounter
- type StatsGenerator
- type StatsManager
- type Tickets
- type TokenFile
- type TokenProvider
- type TurnDataCreator
- type Unicaster
- type User
- type UserStats
- type UserStore
Constants ¶
View Source
const ( RoomTypeConference = "Conference" RoomTypeRoom = "Room" )
View Source
const ( BusManagerStartup = "startup" BusManagerOffer = "offer" BusManagerAnswer = "answer" BusManagerBye = "bye" BusManagerConnect = "connect" BusManagerDisconnect = "disconnect" BusManagerSession = "session" )
View Source
const (
PipelineNamespaceCall = "call"
)
Variables ¶
This section is empty.
Functions ¶
func BusSubjectTrigger ¶
BusSubjectTrigger returns the bus subject for trigger payloads.
func NewDataError ¶
Types ¶
type Broadcaster ¶
type Broadcaster interface {
Broadcast(sessionID, roomID string, outgoing *DataOutgoing)
}
type BusManager ¶
type BusManager interface {
ChannellingAPIConsumer
Start()
Publish(subject string, v interface{}) error
Request(subject string, v interface{}, vPtr interface{}, timeout time.Duration) error
Trigger(name, from, payload string, data interface{}, pipeline *Pipeline) error
Subscribe(subject string, cb nats.Handler) (*nats.Subscription, error)
BindRecvChan(subject string, channel interface{}) (*nats.Subscription, error)
BindSendChan(subject string, channel interface{}) error
PrefixSubject(string) string
CreateSink(string) Sink
}
A BusManager provides the API to interact with a bus.
func NewBusManager ¶
func NewBusManager(apiConsumer ChannellingAPIConsumer, id string, useNats bool, subjectPrefix string) BusManager
NewBusManager creates and initializes a new BusMager with the provided flags for NATS support. It is intended to connect the backend bus with a easy to use API to send and receive bus data.
type BusTrigger ¶
type BusTrigger struct {
Id string
Name string
From string
Payload string `json:",omitempty"`
Data interface{} `json:",omitempty"`
Pipeline string `json:",omitempty"`
}
A BusTrigger is a container to serialize trigger events for the bus backend.
type ByPrioAndStamp ¶
type ByPrioAndStamp []*DataSession
func (ByPrioAndStamp) Len ¶
func (a ByPrioAndStamp) Len() int
func (ByPrioAndStamp) Less ¶
func (a ByPrioAndStamp) Less(i, j int) bool
func (ByPrioAndStamp) Swap ¶
func (a ByPrioAndStamp) Swap(i, j int)
type ChannellingAPI ¶
type ChannellingAPIConsumer ¶
type ChannellingAPIConsumer interface {
SetChannellingAPI(ChannellingAPI)
GetChannellingAPI() ChannellingAPI
}
func NewChannellingAPIConsumer ¶
func NewChannellingAPIConsumer() ChannellingAPIConsumer
type Client ¶
type Client struct {
Connection
Codec
ChannellingAPI ChannellingAPI
// contains filtered or unexported fields
}
func (*Client) OnConnect ¶
func (client *Client) OnConnect(conn Connection)
func (*Client) OnDisconnect ¶
func (client *Client) OnDisconnect()
func (*Client) OnText ¶
func (client *Client) OnText(b buffercache.Buffer)
func (*Client) ReplaceAndClose ¶
type ClientStats ¶
type Codec ¶
type Codec interface {
NewBuffer() buffercache.Buffer
IncomingDecoder
OutgoingEncoder
}
type Config ¶
type Config struct {
Title string // Title
Ver string `json:"-"` // Version (not exported to Javascript)
S string // Static URL prefix with version
B string // Base URL
Token string // Server token
Renegotiation bool // Renegotiation flag
StunURIs []string // STUN server URIs
TurnURIs []string // TURN server URIs
Tokens bool // True when we got a tokens file
Version string // Server version number
UsersEnabled bool // Flag if users are enabled
UsersAllowRegistration bool // Flag if users can register
UsersMode string // Users mode string
DefaultRoomEnabled bool // Flag if default room ("") is enabled
Plugin string // Plugin to load
AuthorizeRoomCreation bool // Whether a user account is required to create rooms
AuthorizeRoomJoin bool // Whether a user account is required to join rooms
Modules []string // List of enabled modules
ModulesTable map[string]bool `json:"-"` // Map of enabled modules
GlobalRoomID string `json:"-"` // Id of the global room (not exported to Javascript)
ContentSecurityPolicy string `json:"-"` // HTML content security policy
ContentSecurityPolicyReportOnly string `json:"-"` // HTML content security policy in report only mode
RoomTypeDefault string `json:"-"` // New rooms default to this type
RoomTypes map[*regexp.Regexp]string `json:"-"` // Map of regular expression -> room type
}
func (*Config) WithModule ¶
type Connection ¶
type Connection interface {
Index() uint64
Send(buffercache.Buffer)
Close()
ReadPump()
WritePump()
}
func NewConnection ¶
func NewConnection(index uint64, ws *websocket.Conn, handler ConnectionHandler) Connection
type ConnectionCounter ¶
type ConnectionCounter interface {
CountConnection() uint64
}
type ConnectionHandler ¶
type ConnectionHandler interface {
NewBuffer() buffercache.Buffer
OnConnect(Connection)
OnDisconnect()
OnText(buffercache.Buffer)
}
type ContactManager ¶
type Context ¶
type Context struct {
App string // Main client script
Cfg *Config
Host string
Ssl bool
Csp bool
Languages []string
Room string `json:"-"`
Scheme string `json:"-"`
Origin string `json:",omitempty"`
S string `json:",omitempty"`
ExtraDHead template.HTML `json:"-"`
ExtraDBody template.HTML `json:"-"`
}
type DataAnswer ¶
type DataAuthentication ¶
type DataAuthentication struct {
Type string
Authentication *SessionToken
}
type DataAutoCall ¶
type DataCandidate ¶
type DataChat ¶
type DataChat struct {
To string
Type string
Chat *DataChatMessage
}
type DataChatMessage ¶
type DataChatMessage struct {
Message string
Time string
NoEcho bool `json:",omitempty"`
Mid string `json:",omitempty"`
Status *DataChatStatus
}
type DataChatStatus ¶
type DataChatStatus struct {
Typing string `json:",omitempty"`
State string `json:",omitempty"`
Mid string `json:",omitempty"`
SeenMids []string `json:",omitempty"`
FileInfo *DataFileInfo `json:",omitempty"`
Geolocation *DataGeolocation `json:",omitempty"`
ContactRequest *DataContactRequest `json:",omitempty"`
AutoCall *DataAutoCall `json:",omitempty"`
}
type DataConference ¶
type DataContactRequest ¶
type DataFileInfo ¶
type DataGeolocation ¶
type DataIncoming ¶
type DataIncoming struct {
Type string
Hello *DataHello `json:",omitempty"`
Offer *DataOffer `json:",omitempty"`
Candidate *DataCandidate `json:",omitempty"`
Answer *DataAnswer `json:",omitempty"`
Bye *DataBye `json:",omitempty"`
Status *DataStatus `json:",omitempty"`
Chat *DataChat `json:",omitempty"`
Conference *DataConference `json:",omitempty"`
Alive *DataAlive `json:",omitempty"`
Authentication *DataAuthentication `json:",omitempty"`
Sessions *DataSessions `json:",omitempty"`
Room *DataRoom `json:",omitempty"`
Iid string `json:",omitempty"`
}
type DataOutgoing ¶
type DataRoom ¶
type DataRoom struct {
Type string // Room type.
Name string // Room name.
Credentials *DataRoomCredentials
}
type DataRoomCredentials ¶
type DataRoomCredentials struct {
PIN string
}
type DataSession ¶
type DataSession struct {
Type string
Id string
Userid string `json:",omitempty"`
Ua string `json:",omitempty"`
Token string `json:",omitempty"`
Version string `json:",omitempty"`
Rev uint64 `json:",omitempty"`
Prio int `json:",omitempty"`
Status interface{} `json:",omitempty"`
// contains filtered or unexported fields
}
type DataSessions ¶
type DataSessions struct {
Type string
Sessions *DataSessionsRequest `json:",omitempty"`
Users []*DataSession
}
type DataSessionsRequest ¶
type DataSinkOutgoing ¶
type DataSinkOutgoing struct {
Outgoing *DataOutgoing
ToUserid string
FromUserid string
Pipe string `json:",omitempty"`
}
type DataStatus ¶
type DataStatus struct {
Type string
Status interface{}
}
type DataWelcome ¶
type DataWelcome struct {
Type string
Room *DataRoom
Users []*DataSession
}
type Hub ¶
type Hub interface {
ClientStats
Unicaster
TurnDataCreator
ContactManager
}
type HubStat ¶
type HubStat struct {
Rooms int `json:"rooms"`
Connections int `json:"connections"`
Sessions int `json:"sessions"`
Users int `json:"users"`
Count uint64 `json:"count"`
BroadcastChatMessages uint64 `json:"broadcastchatmessages"`
UnicastChatMessages uint64 `json:"unicastchatmessages"`
IdsInRoom map[string][]string `json:"idsinroom,omitempty"`
SessionsById map[string]*DataSession `json:"sessionsbyid,omitempty"`
UsersById map[string]*DataUser `json:"usersbyid,omitempty"`
ConnectionsByIdx map[string]string `json:"connectionsbyidx,omitempty"`
}
type Image ¶
type Image struct {
// contains filtered or unexported fields
}
func (*Image) LastChange ¶
func (*Image) LastChangeID ¶
type ImageCache ¶
type ImageCache interface {
Update(sessionId string, image string) string
Get(imageId string) *Image
Delete(sessionId string)
}
func NewImageCache ¶
func NewImageCache() ImageCache
type IncomingDecoder ¶
type IncomingDecoder interface {
DecodeIncoming(buffercache.Buffer) (*DataIncoming, error)
}
type OutgoingEncoder ¶
type OutgoingEncoder interface {
EncodeOutgoing(*DataOutgoing) (buffercache.Buffer, error)
}
type Pipeline ¶
type Pipeline struct {
PipelineManager PipelineManager
// contains filtered or unexported fields
}
func NewPipeline ¶
func (*Pipeline) Add ¶
func (pipeline *Pipeline) Add(msg *DataSinkOutgoing) *Pipeline
func (*Pipeline) FlushOutgoing ¶
func (*Pipeline) FromSession ¶
func (*Pipeline) Send ¶
func (pipeline *Pipeline) Send(b buffercache.Buffer)
type PipelineFeedLine ¶
type PipelineFeedLine struct {
Seq int
Msg *DataOutgoing
}
type PipelineManager ¶
type PipelineManager interface {
BusManager
SessionStore
UserStore
SessionCreator
GetPipelineByID(id string) (pipeline *Pipeline, ok bool)
GetPipeline(namespace string, sender Sender, session *Session, to string) *Pipeline
FindSinkAndSession(to string) (Sink, *Session)
}
func NewPipelineManager ¶
func NewPipelineManager(busManager BusManager, sessionStore SessionStore, userStore UserStore, sessionCreator SessionCreator) PipelineManager
type RoomManager ¶
type RoomManager interface {
RoomStatusManager
Broadcaster
RoomStats
SetBusManager(bus BusManager) error
}
func NewRoomManager ¶
func NewRoomManager(config *Config, encoder OutgoingEncoder) RoomManager
type RoomStatusManager ¶
type RoomStatusManager interface {
RoomUsers(*Session) []*DataSession
JoinRoom(roomID, roomName, roomType string, credentials *DataRoomCredentials, session *Session, sessionAuthenticated bool, sender Sender) (*DataRoom, error)
LeaveRoom(roomID, sessionID string)
UpdateRoom(*Session, *DataRoom) (*DataRoom, error)
MakeRoomID(roomName, roomType string) string
Get(roomID string) (room RoomWorker, ok bool)
}
type RoomWorker ¶
type RoomWorker interface {
Start()
SessionIDs() []string
Users() []*roomUser
Update(*DataRoom) error
GetUsers() []*DataSession
Broadcast(sessionID string, buf buffercache.Buffer)
Join(*DataRoomCredentials, *Session, Sender) (*DataRoom, error)
Leave(sessionID string)
GetType() string
}
func NewRoomWorker ¶
func NewRoomWorker(manager *roomManager, roomID, roomName, roomType string, credentials *DataRoomCredentials) RoomWorker
type Sender ¶
type Sender interface {
Index() uint64
Send(buffercache.Buffer)
}
type Session ¶
type Session struct {
SessionManager SessionManager
Unicaster Unicaster
Broadcaster Broadcaster
RoomStatusManager RoomStatusManager
Id string
Sid string
Ua string
UpdateRev uint64
Status interface{}
Nonce string
Prio int
Hello bool
Roomid string
// contains filtered or unexported fields
}
func NewSession ¶
func NewSession(manager SessionManager, unicaster Unicaster, broadcaster Broadcaster, rooms RoomStatusManager, buddyImages ImageCache, attestations *securecookie.SecureCookie, id, sid string) *Session
func (*Session) AddSubscriber ¶
func (*Session) Authenticate ¶
func (s *Session) Authenticate(realm string, st *SessionToken, userid string) error
func (*Session) Authorize ¶
func (s *Session) Authorize(realm string, st *SessionToken) (string, error)
func (*Session) BroadcastStatus ¶
func (s *Session) BroadcastStatus()
func (*Session) Data ¶
func (s *Session) Data() *DataSession
func (*Session) DecodeAttestation ¶
func (*Session) NewAttestation ¶
func (s *Session) NewAttestation()
func (*Session) RemoveSubscriber ¶
func (*Session) SetUseridFake ¶
func (*Session) Token ¶
func (s *Session) Token() *SessionToken
func (*Session) Unsubscribe ¶
func (*Session) Update ¶
func (s *Session) Update(update *SessionUpdate) uint64
func (*Session) UpdateAttestation ¶
type SessionAttestation ¶
type SessionAttestation struct {
// contains filtered or unexported fields
}
func (*SessionAttestation) Decode ¶
func (sa *SessionAttestation) Decode(token string) (string, error)
func (*SessionAttestation) Encode ¶
func (sa *SessionAttestation) Encode() (string, error)
func (*SessionAttestation) Token ¶
func (sa *SessionAttestation) Token() (token string)
func (*SessionAttestation) Update ¶
func (sa *SessionAttestation) Update() (string, error)
type SessionCreateRequest ¶
type SessionCreateRequest struct {
Id string
Session *DataSession
Room *DataRoom
SetAsDefault bool
}
type SessionCreator ¶
type SessionCreator interface {
CreateSession(st *SessionToken, userid string) *Session
}
type SessionEncoder ¶
type SessionManager ¶
type SessionManager interface {
UserStats
SessionStore
UserStore
SessionCreator
DestroySession(sessionID, userID string)
Authenticate(*Session, *SessionToken, string) error
GetUserSessions(session *Session, id string) []*DataSession
DecodeSessionToken(token string) (st *SessionToken)
}
func NewSessionManager ¶
func NewSessionManager(config *Config, tickets Tickets, unicaster Unicaster, broadcaster Broadcaster, rooms RoomStatusManager, buddyImages ImageCache, sessionSecret []byte) SessionManager
type SessionStore ¶
type SessionToken ¶
type SessionUpdate ¶
type SessionValidator ¶
type Sink ¶
type Sink interface {
// Write sends outgoing data on the sink
Write(*DataSinkOutgoing) error
Enabled() bool
Close()
Export() *DataSink
BindRecvChan(channel interface{}) (*nats.Subscription, error)
}
Sink connects a Pipeline with end points in both directions by getting attached to a Pipeline.
type StatsCounter ¶
type StatsCounter interface {
CountBroadcastChat()
CountUnicastChat()
}
type StatsGenerator ¶
type StatsManager ¶
type StatsManager interface {
ConnectionCounter
StatsCounter
StatsGenerator
}
func NewStatsManager ¶
func NewStatsManager(clientStats ClientStats, roomStats RoomStats, userStats UserStats) StatsManager
type Tickets ¶
type Tickets interface {
SessionValidator
SessionEncoder
DecodeSessionToken(token string) (st *SessionToken)
FakeSessionToken(userid string) *SessionToken
}
func NewTickets ¶
type TokenFile ¶
func (*TokenFile) ReloadIfModified ¶
type TokenProvider ¶
func TokenFileProvider ¶
func TokenFileProvider(filename string) TokenProvider
type TurnDataCreator ¶
type Unicaster ¶
type Unicaster interface {
SessionStore
OnConnect(*Client, *Session)
OnDisconnect(*Client, *Session)
Unicast(to string, outgoing *DataOutgoing, pipeline *Pipeline)
}
type User ¶
type User struct {
Id string
// contains filtered or unexported fields
}
func (*User) AddSession ¶
AddSession adds a session to the session table and returns true if s is the first session.
func (*User) RemoveSession ¶
RemoveSession removes a session from the session table abd returns true if no session is left left.
func (*User) SubscribeSessions ¶
func (u *User) SubscribeSessions(from *Session) []*DataSession
Source Files
¶
- api.go
- bus.go
- bus_manager.go
- client.go
- clientstats.go
- codec.go
- config.go
- connection.go
- contact.go
- contact_manager.go
- context.go
- data.go
- hub.go
- imagecache.go
- pipeline.go
- pipeline_manager.go
- room_manager.go
- roomworker.go
- session.go
- session_manager.go
- sessionattestation.go
- sessioncreator.go
- sessionstore.go
- sessiontoken.go
- sessionupdate.go
- sink.go
- stats_manager.go
- tickets.go
- tokenprovider.go
- turndata.go
- unicaster.go
- user.go
- userstore.go
Click to show internal directories.
Click to hide internal directories.