2023-01-11 06:38:48 +00:00
|
|
|
package barertc
|
|
|
|
|
|
|
|
type Message struct {
|
|
|
|
Action string `json:"action,omitempty"`
|
2023-01-27 06:54:02 +00:00
|
|
|
Username string `json:"username,omitempty"`
|
|
|
|
Message string `json:"message",omitempty`
|
2023-01-27 04:34:58 +00:00
|
|
|
|
|
|
|
// WhoList for `who` actions
|
2023-01-27 06:54:02 +00:00
|
|
|
WhoList []WhoList `json:"whoList,omitempty"`
|
2023-01-27 04:34:58 +00:00
|
|
|
|
|
|
|
// Sent on `me` actions along with Username
|
2023-01-27 06:54:02 +00:00
|
|
|
VideoActive bool `json:"videoActive,omitempty"` // user tells us their cam status
|
|
|
|
|
|
|
|
// Sent on `open` actions along with the (other) Username.
|
|
|
|
OpenSecret string `json:"openSecret,omitempty"`
|
|
|
|
|
|
|
|
// Parameters sent on WebRTC signaling messages.
|
2023-02-05 05:00:01 +00:00
|
|
|
Candidate map[string]interface{} `json:"candidate,omitempty"` // candidate
|
|
|
|
Description map[string]interface{} `json:"description,omitempty"` // sdp
|
2023-01-11 06:38:48 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
const (
|
2023-01-27 04:34:58 +00:00
|
|
|
// Actions sent by the client side only
|
|
|
|
ActionLogin = "login" // post the username to backend
|
|
|
|
|
|
|
|
// Actions sent by server or client
|
2023-01-11 06:38:48 +00:00
|
|
|
ActionMessage = "message" // post a message to the room
|
2023-01-27 04:34:58 +00:00
|
|
|
ActionMe = "me" // user self-info sent by FE or BE
|
2023-01-27 06:54:02 +00:00
|
|
|
ActionOpen = "open" // user wants to view a webcam (open WebRTC)
|
|
|
|
ActionRing = "ring" // receiver of a WebRTC open request
|
2023-01-27 04:34:58 +00:00
|
|
|
|
|
|
|
// Actions sent by server only
|
2023-02-05 05:00:01 +00:00
|
|
|
ActionPing = "ping"
|
2023-01-27 04:34:58 +00:00
|
|
|
ActionWhoList = "who" // server pushes the Who List
|
|
|
|
ActionPresence = "presence" // a user joined or left the room
|
2023-01-27 06:54:02 +00:00
|
|
|
ActionError = "error" // ChatServer errors
|
|
|
|
|
|
|
|
// WebRTC signaling messages.
|
|
|
|
ActionCandidate = "candidate"
|
|
|
|
ActionSDP = "sdp"
|
2023-01-11 06:38:48 +00:00
|
|
|
)
|
2023-01-27 04:34:58 +00:00
|
|
|
|
|
|
|
// WhoList is a member entry in the chat room.
|
|
|
|
type WhoList struct {
|
|
|
|
Username string `json:"username"`
|
|
|
|
VideoActive bool `json:"videoActive"`
|
|
|
|
}
|