diff --git a/server/api/api.go b/server/api/api.go index 6b4e682..9f8caa2 100644 --- a/server/api/api.go +++ b/server/api/api.go @@ -40,6 +40,7 @@ func NewApi(rdb *redis.Client, live777Url string, live777Token string) http.Hand //r.Patch("/room/{roomId}", handle.UpdateRoom) r.Post("/room/{roomId}/stream", handle.CreateRoomStream) r.Patch("/room/{roomId}/stream/{streamId}", handle.UpdateRoomStream) + r.Delete("/room/{roomId}/stream/{streamId}", handle.DestroyRoomStream) //r.Post("/room/{roomId}/message", handle.CreateMessage) //r.Get("/room/{roomId}/message", handle.ShowMessage) diff --git a/server/api/v1/stream.go b/server/api/v1/stream.go index 421202f..08cd42b 100644 --- a/server/api/v1/stream.go +++ b/server/api/v1/stream.go @@ -1,6 +1,7 @@ package v1 import ( + "context" "net/http" "woom/server/model" @@ -50,3 +51,14 @@ func (h *Handler) UpdateRoomStream(w http.ResponseWriter, r *http.Request) { room.StreamId = streamId render.JSON(w, r, room) } + +func (h *Handler) DestroyRoomStream(w http.ResponseWriter, r *http.Request) { + roomId := chi.URLParam(r, "roomId") + streamId := chi.URLParam(r, "streamId") + + if err := h.rdb.HDel(context.TODO(), roomId, streamId,).Err(); err != nil { + w.WriteHeader(http.StatusInternalServerError) + w.Write([]byte(err.Error())) + return + } +} diff --git a/webapp/components/layout.tsx b/webapp/components/layout.tsx index eb8af6a..83b94f4 100644 --- a/webapp/components/layout.tsx +++ b/webapp/components/layout.tsx @@ -42,8 +42,10 @@ export default function Layout(props: { meetingId: string }) { } const callEnd = async () => { - // TODO: - // need clear server status + await fetch(`/room/${props.meetingId}/stream/${localStreamId}`, { + method: "DELETE" + }) + setMeetingJoined(false) }