Skip to content

Commit

Permalink
feat(server): add stream delete
Browse files Browse the repository at this point in the history
  • Loading branch information
a-wing committed Dec 30, 2023
1 parent 127b147 commit bfa7578
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 2 deletions.
1 change: 1 addition & 0 deletions server/api/api.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
12 changes: 12 additions & 0 deletions server/api/v1/stream.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package v1

import (
"context"
"net/http"
"woom/server/model"

Expand Down Expand Up @@ -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
}
}
6 changes: 4 additions & 2 deletions webapp/components/layout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}

Expand Down

0 comments on commit bfa7578

Please sign in to comment.