Documentation ¶
Overview ¶
Package janus is a Golang implementation of the Janus API, used to interact with the Janus WebRTC Gateway.
Index ¶
- func WaitForGroup(g *errgroup.Group) error
- type AckMsg
- type BaseMsg
- type DetachedMsg
- type ErrorData
- type ErrorMsg
- type EventMsg
- type Gateway
- type Handle
- func (handle *Handle) Detach(ctx context.Context, token string) (*AckMsg, error)
- func (handle *Handle) Message(ctx context.Context, token string, body, jsep interface{}) (*EventMsg, error)
- func (handle *Handle) Request(ctx context.Context, token string, body interface{}) (*SuccessMsg, error)
- func (handle *Handle) Trickle(ctx context.Context, token string, candidate interface{}) (*AckMsg, error)
- func (handle *Handle) TrickleMany(ctx context.Context, token string, candidates interface{}) (*AckMsg, error)
- type HangupMsg
- type InfoMsg
- type MediaMsg
- type PluginData
- type PluginInfo
- type Session
- func (session *Session) Attach(ctx context.Context, token, plugin string) (*Handle, error)
- func (session *Session) Destroy(ctx context.Context, token string) (*AckMsg, error)
- func (session *Session) KeepAlive(ctx context.Context, token string) (*AckMsg, error)
- func (session *Session) KeepAliveSender(ctx context.Context) error
- type SlowLinkMsg
- type SuccessData
- type SuccessMsg
- type TimeoutMsg
- type WebRTCUpMsg
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func WaitForGroup ¶
WaitForGroup is an example of wait and catch errors from the Connect() function
Types ¶
type DetachedMsg ¶
type DetachedMsg struct{}
type EventMsg ¶
type EventMsg struct { Plugindata PluginData Jsep map[string]interface{} Session uint64 `json:"session_id"` Handle uint64 `json:"sender"` }
type Gateway ¶
type Gateway struct { // Sessions is a map of the currently active sessions to the gateway. Sessions map[uint64]*Session // Access to the Sessions map should be synchronized with the Gateway.Lock() // and Gateway.Unlock() methods provided by the embeded sync.Mutex. sync.Mutex // LogJsonMessages enables logging of json rx/tx messages to stdout LogJsonMessages bool // contains filtered or unexported fields }
Gateway represents a connection to an instance of the Janus Gateway.
func Connect ¶
Connect initiates a websock connection with the Janus Gateway
It will also spawn two goroutines to maintain the connection One is for sending Websocket ping messages periodically The other is for reading messages and passing to the right channel
These two goroutines are added to an errgroup.Group which you can ignore if you like: gateway, _, err := janus.Connect or even better you can use the Wait() method to wait for these methods, AND CATCH ANY ERRORS THAT OCCUR inside of them. The readme has links to more info on errgroup.
func (*Gateway) Close ¶
func (gateway *Gateway) Close(code websocket.StatusCode, reason string) error
Close closes the underlying connection to the Gateway.
type Handle ¶
type Handle struct { // ID is the handle_id of this plugin handle ID uint64 // Type // pub or sub Type string //User // Userid User string // Events is a receive only channel that can be used to receive events // related to this handle from the gateway. Events chan interface{} // contains filtered or unexported fields }
Handle represents a handle to a plugin instance on the Gateway.
func (*Handle) Detach ¶
Detach sends a detach request to the Gateway to remove this handle. On success, an AckMsg will be returned and error will be nil.
func (*Handle) Message ¶
func (handle *Handle) Message(ctx context.Context, token string, body, jsep interface{}) (*EventMsg, error)
Message sends a message request to a plugin handle on the Gateway. body should be the plugin data to be passed to the plugin, and jsep should contain an optional SDP offer/answer to establish a WebRTC PeerConnection. On success, an EventMsg will be returned and error will be nil.
func (*Handle) Request ¶
func (handle *Handle) Request(ctx context.Context, token string, body interface{}) (*SuccessMsg, error)
Request sends a sync request
func (*Handle) Trickle ¶
func (handle *Handle) Trickle(ctx context.Context, token string, candidate interface{}) (*AckMsg, error)
Trickle sends a trickle request to the Gateway as part of establishing a new PeerConnection with a plugin. candidate should be a single ICE candidate, or a completed object to signify that all candidates have been sent:
{ "completed": true }
On success, an AckMsg will be returned and error will be nil.
func (*Handle) TrickleMany ¶
func (handle *Handle) TrickleMany(ctx context.Context, token string, candidates interface{}) (*AckMsg, error)
TrickleMany sends a trickle request to the Gateway as part of establishing a new PeerConnection with a plugin. candidates should be an array of ICE candidates. On success, an AckMsg will be returned and error will be nil.
type PluginData ¶
type PluginInfo ¶
type Session ¶
type Session struct { // ID is the session_id of this session ID uint64 // Handles is a map of plugin handles within this session Handles map[uint64]*Handle Events chan interface{} // Access to the Handles map should be synchronized with the Session.Lock() // and Session.Unlock() methods provided by the embeded sync.Mutex. sync.Mutex // contains filtered or unexported fields }
Session represents a session instance on the Janus Gateway.
func (*Session) Attach ¶
Attach sends an attach request to the Gateway within this session. plugin should be the unique string of the plugin to attach to. On success, a new Handle will be returned and error will be nil.
func (*Session) Destroy ¶
Destroy sends a destroy request to the Gateway to tear down this session. On success, the Session will be removed from the Gateway.Sessions map, an AckMsg will be returned and error will be nil.
type SlowLinkMsg ¶
type SuccessData ¶
type SuccessData struct {
ID uint64
}
type SuccessMsg ¶
type SuccessMsg struct { Data SuccessData PluginData PluginData Session uint64 `json:"session_id"` Handle uint64 `json:"sender"` }
type TimeoutMsg ¶
type TimeoutMsg struct {
Session uint64 `json:"session_id"`
}