mirror of
https://github.com/m1k1o/neko.git
synced 2024-07-24 14:40:50 +12:00
memberId to sessionId.
This commit is contained in:
parent
d83e04e7ec
commit
b03a730c84
@ -42,7 +42,7 @@ func (h *RoomHandler) controlRequest(w http.ResponseWriter, r *http.Request) {
|
|||||||
|
|
||||||
session := auth.GetSession(r)
|
session := auth.GetSession(r)
|
||||||
if !session.CanHost() {
|
if !session.CanHost() {
|
||||||
utils.HttpBadRequest(w, "Member is not allowed to host.")
|
utils.HttpBadRequest(w, "Session is not allowed to host.")
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -54,12 +54,12 @@ func (h *RoomHandler) controlRequest(w http.ResponseWriter, r *http.Request) {
|
|||||||
func (h *RoomHandler) controlRelease(w http.ResponseWriter, r *http.Request) {
|
func (h *RoomHandler) controlRelease(w http.ResponseWriter, r *http.Request) {
|
||||||
session := auth.GetSession(r)
|
session := auth.GetSession(r)
|
||||||
if !session.IsHost() {
|
if !session.IsHost() {
|
||||||
utils.HttpUnprocessableEntity(w, "Member is not the host.")
|
utils.HttpUnprocessableEntity(w, "Session is not the host.")
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
if !session.CanHost() {
|
if !session.CanHost() {
|
||||||
utils.HttpBadRequest(w, "Member is not allowed to host.")
|
utils.HttpBadRequest(w, "Session is not allowed to host.")
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -72,7 +72,7 @@ func (h *RoomHandler) controlRelease(w http.ResponseWriter, r *http.Request) {
|
|||||||
func (h *RoomHandler) controlTake(w http.ResponseWriter, r *http.Request) {
|
func (h *RoomHandler) controlTake(w http.ResponseWriter, r *http.Request) {
|
||||||
session := auth.GetSession(r)
|
session := auth.GetSession(r)
|
||||||
if !session.CanHost() {
|
if !session.CanHost() {
|
||||||
utils.HttpBadRequest(w, "Member is not allowed to host.")
|
utils.HttpBadRequest(w, "Session is not allowed to host.")
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -82,16 +82,16 @@ func (h *RoomHandler) controlTake(w http.ResponseWriter, r *http.Request) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (h *RoomHandler) controlGive(w http.ResponseWriter, r *http.Request) {
|
func (h *RoomHandler) controlGive(w http.ResponseWriter, r *http.Request) {
|
||||||
memberId := chi.URLParam(r, "memberId")
|
sessionId := chi.URLParam(r, "sessionId")
|
||||||
|
|
||||||
target, ok := h.sessions.Get(memberId)
|
target, ok := h.sessions.Get(sessionId)
|
||||||
if !ok {
|
if !ok {
|
||||||
utils.HttpNotFound(w, "Target member was not found.")
|
utils.HttpNotFound(w, "Target session was not found.")
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
if !target.CanHost() {
|
if !target.CanHost() {
|
||||||
utils.HttpBadRequest(w, "Target member is not allowed to host.")
|
utils.HttpBadRequest(w, "Target session is not allowed to host.")
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -23,11 +23,12 @@ func (h *MessageHandlerCtx) systemInit(session types.Session) error {
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// TODO: Sessions.
|
||||||
members := map[string]message.MemberData{}
|
members := map[string]message.MemberData{}
|
||||||
for _, session := range h.sessions.List() {
|
for _, session := range h.sessions.List() {
|
||||||
memberId := session.ID()
|
sessionId := session.ID()
|
||||||
members[memberId] = message.MemberData{
|
members[sessionId] = message.MemberData{
|
||||||
ID: memberId,
|
ID: sessionId,
|
||||||
Profile: session.GetProfile(),
|
Profile: session.GetProfile(),
|
||||||
State: session.GetState(),
|
State: session.GetState(),
|
||||||
}
|
}
|
||||||
@ -36,6 +37,7 @@ func (h *MessageHandlerCtx) systemInit(session types.Session) error {
|
|||||||
return session.Send(
|
return session.Send(
|
||||||
message.SystemInit{
|
message.SystemInit{
|
||||||
Event: event.SYSTEM_INIT,
|
Event: event.SYSTEM_INIT,
|
||||||
|
// TODO: Session ID.
|
||||||
MemberId: session.ID(),
|
MemberId: session.ID(),
|
||||||
ControlHost: controlHost,
|
ControlHost: controlHost,
|
||||||
ScreenSize: message.ScreenSize{
|
ScreenSize: message.ScreenSize{
|
||||||
@ -43,6 +45,7 @@ func (h *MessageHandlerCtx) systemInit(session types.Session) error {
|
|||||||
Height: size.Height,
|
Height: size.Height,
|
||||||
Rate: size.Rate,
|
Rate: size.Rate,
|
||||||
},
|
},
|
||||||
|
// TODO: Sessions.
|
||||||
Members: members,
|
Members: members,
|
||||||
ImplicitHosting: h.sessions.ImplicitHosting(),
|
ImplicitHosting: h.sessions.ImplicitHosting(),
|
||||||
})
|
})
|
||||||
|
Loading…
Reference in New Issue
Block a user