You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
34 lines
807 B
Go
34 lines
807 B
Go
package room
|
|
|
|
import (
|
|
"movie-sync-server/entities"
|
|
|
|
"github.com/sirupsen/logrus"
|
|
"github.com/zishang520/socket.io/v2/socket"
|
|
)
|
|
|
|
func SetUrlEndpoint(client *socket.Socket, cliMsg *entities.ClientMessage) []byte {
|
|
room, videoUrls := cliMsg.Room, cliMsg.VideoUrls
|
|
userID := string(client.Id())
|
|
if r, ok := entities.GetCinema().GetRoom(room); ok {
|
|
u := r.GetUser(userID)
|
|
if u != nil {
|
|
if !u.IsAdmin() {
|
|
u.Send(entities.MessageTypeMessage, entities.ServerNotificationMessage{
|
|
Type: entities.MessageTypeMessage,
|
|
Severity: "error",
|
|
Title: "错误",
|
|
Message: "只有房间管理员可以设置URL",
|
|
})
|
|
return nil
|
|
}
|
|
|
|
r.SetUrls(videoUrls)
|
|
r.BroadcastRoomState()
|
|
}
|
|
} else {
|
|
logrus.Warnf("room [%s] not found, can not set url", room)
|
|
}
|
|
return nil
|
|
}
|