Documentation ¶
Index ¶
- type Broadcast
- type Cors
- type EventEmitter
- type IEventEmitter
- type Options
- type Peer
- func (p *Peer) AddCandidate(can webrtc.ICECandidateInit) []webrtc.ICECandidateInit
- func (p *Peer) Broadcast(roomIds ...string) Broadcast
- func (p *Peer) Disconnect()
- func (p *Peer) Emit(e string, msg ...string)
- func (p *Peer) Join(ids ...string)
- func (p *Peer) Leave(ids ...string)
- func (p *Peer) Reliable(interval int, runs int) *Peer
- func (p *Peer) Room(roomIds ...string) Room
- func (p *Peer) Rooms() []string
- type Room
- type Server
- func (s *Server) CreateConnection(w http.ResponseWriter, r *http.Request)
- func (s *Server) Listen(port int) error
- func (s *Server) OnConnection(f func(c *Peer))
- func (s *Server) OnDisconnect(f func(c *Peer))
- func (s *Server) SendAdditionalCandidates(w http.ResponseWriter, r *http.Request)
- func (s *Server) SetRemoteDescription(w http.ResponseWriter, r *http.Request)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type EventEmitter ¶
type EventEmitter struct {
// contains filtered or unexported fields
}
func (*EventEmitter) Emit ¶
func (em *EventEmitter) Emit(evt string, args ...interface{}) bool
func (*EventEmitter) Off ¶
func (em *EventEmitter) Off(e string, listener interface{}) bool
func (*EventEmitter) On ¶
func (em *EventEmitter) On(e string, listener interface{}) IEventEmitter
type IEventEmitter ¶
type IEventEmitter interface { On(evt string, listener interface{}) IEventEmitter Off(e string, listener interface{}) bool Emit(evt string, args ...interface{}) bool }
func CreateEventEmitter ¶
func CreateEventEmitter() IEventEmitter
type Options ¶
type Options struct { Ordered bool // Only effective when using gecgos.io provided HTTP server Cors // Disables gecgos.io provided HTTP server DisableHttpServer bool // If defined, bind only to the given local address if it exists BindAddress string // Sets a list of external IP addresses of 1:1 (D)NAT and a candidate type for which the external IP address is used. // This is useful when you host a server using Pion on an AWS EC2 instance which has a private address, behind a 1:1 DNAT with a public IP (e.g. Elastic IP). NAT1To1IPs []string }
type Peer ¶
type Peer struct { Id string IEventEmitter // contains filtered or unexported fields }
The server's definition of a client
func (*Peer) AddCandidate ¶
func (p *Peer) AddCandidate(can webrtc.ICECandidateInit) []webrtc.ICECandidateInit
func (*Peer) Broadcast ¶
Returns a list of peers given roomIds, NOT including sender.
If no roomIds are given, returns all peers from all rooms the sender is in.
If the sender is not in a room, returns no peers.
func (*Peer) Disconnect ¶
func (p *Peer) Disconnect()
func (*Peer) Emit ¶
Send a message to peer
- e: The event as a string
- msg: The message as a string (optional)
Example usage:
peer.Emit("x", "hello") // with message "hello" peer.Emit("y", "hello", "world") // with message "hello, world" peer.Emit("z") // with no message
func (*Peer) Reliable ¶
Will make the next Emit call to be reliable
- interval: The interval between each message in ms
- runs: How many times the message should be sent
Example usage:
peer.Reliable(150, 10).Emit("ping", "hello") // reliable peer.Emit("pong", "world") // no longer reliable
type Server ¶
type Server struct { Options Rooms map[string]Room IEventEmitter // contains filtered or unexported fields }
func (*Server) CreateConnection ¶
func (s *Server) CreateConnection(w http.ResponseWriter, r *http.Request)
This function will try to prepare a WebRTC connection by first offering the SDP challenge to the potential client https://github.com/geckosio/geckos.io/blob/1d15c1ae8877b62f53fa026de2323c09202b07ab/packages/server/src/wrtc/connectionsManager.ts#L50
func (*Server) Listen ¶
Make the server listen on a specific port
If DisableHttpHandler is true, Listen() will no longer be blocking
func (*Server) OnConnection ¶
func (*Server) OnDisconnect ¶
func (*Server) SendAdditionalCandidates ¶
func (s *Server) SendAdditionalCandidates(w http.ResponseWriter, r *http.Request)
This function will send the client additional ice candidates to aid in connection https://github.com/geckosio/geckos.io/blob/6ad2535a8f26d6cce0e7af2c4cf7df311622b567/packages/server/src/httpServer/routes.ts#L68
func (*Server) SetRemoteDescription ¶
func (s *Server) SetRemoteDescription(w http.ResponseWriter, r *http.Request)
This function will try to accept the SDP challenge from a potential client https://github.com/geckosio/geckos.io/blob/6ad2535a8f26d6cce0e7af2c4cf7df311622b567/packages/server/src/httpServer/routes.ts#L38