2023-01-11 06:38:48 +00:00
|
|
|
package barertc
|
|
|
|
|
2023-02-06 21:27:29 +00:00
|
|
|
import "time"
|
|
|
|
|
2023-01-11 06:38:48 +00:00
|
|
|
type Message struct {
|
2023-02-06 21:27:29 +00:00
|
|
|
Action string `json:"action,omitempty"`
|
|
|
|
Channel string `json:"channel,omitempty"`
|
|
|
|
Username string `json:"username,omitempty"`
|
|
|
|
Message string `json:"message,omitempty"`
|
|
|
|
Timestamp time.Time `json:"at,omitempty"`
|
2023-01-27 04:34:58 +00:00
|
|
|
|
2023-02-06 01:42:09 +00:00
|
|
|
// JWT token for `login` actions.
|
|
|
|
JWTToken string `json:"jwt,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-02-06 04:26:00 +00:00
|
|
|
ActionWatch = "watch" // user has received video and is watching you
|
|
|
|
ActionUnwatch = "unwatch" // user has closed your video
|
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"`
|
2023-02-06 01:42:09 +00:00
|
|
|
|
|
|
|
// JWT auth extra settings.
|
|
|
|
Operator bool `json:"op"`
|
|
|
|
Avatar string `json:"avatar"`
|
|
|
|
ProfileURL string `json:"profileURL"`
|
2023-01-27 04:34:58 +00:00
|
|
|
}
|