Documentation
¶
Index ¶
Constants ¶
View Source
const ( MessageTypeAnswer = "answer" MessageTypeCandidate = "candidate" MessageTypeOffer = "offer" MessageTypeInfo = "info" )
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Client ¶
type Client struct {
// Buffered channel of outbound messages.
Send chan []byte
// webRTC peer connection
PeerConnection *webrtc.PeerConnection
// contains filtered or unexported fields
}
Client is a middleman between the websocket connection and the hub.
func (*Client) ReadLoop ¶
func (c *Client) ReadLoop()
ReadLoop pumps messages from the websocket connection to the hub.
The application runs ReadLoop in a per-connection goroutine. The application ensures that there is at most one reader on a connection by executing all reads from this goroutine.
func (*Client) WriteLoop ¶
func (c *Client) WriteLoop()
WriteLoop pumps messages from the hub to the websocket connection.
A goroutine running WriteLoop is started for each connection. The application ensures that there is at most one writer to a connection by executing all writes from this goroutine.
type Hub ¶
type Hub struct {
// Registered Clients.
Clients map[*Client]struct{}
// Broadcast messages to all Clients.
Broadcast chan []byte
// Register a new client to the hub.
Register chan *Client
// Unregister a client from the hub.
Unregister chan *Client
// lock to prevent write to closed channel
sync.RWMutex
}
type WebsocketMessage ¶
type WebsocketMessage struct {
Event string `json:"event"`
Data json.RawMessage `json:"data"`
}
Click to show internal directories.
Click to hide internal directories.