Skip to content

Commit

Permalink
set whipclient publish token=user.token for /wh[i,e]p/{uuid} api.go h…
Browse files Browse the repository at this point in the history
…andler
  • Loading branch information
WinterJack002 committed Nov 25, 2024
1 parent 760d16b commit d4b4472
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 6 deletions.
7 changes: 3 additions & 4 deletions server/api/api.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import (
"net/url"

woomMiddleware "woom/server/api/middleware"
"woom/server/api/v1"
v1 "woom/server/api/v1"
"woom/server/helper"
"woom/static"

Expand Down Expand Up @@ -49,16 +49,15 @@ func NewApi(rdb *redis.Client, secret string, live777Url string, live777Token st
r.Post("/room/{roomId}/stream", handle.CreateRoomStream)
r.Patch("/room/{roomId}/stream/{streamId}", handle.UpdateRoomStream)
r.Delete("/room/{roomId}/stream/{streamId}", handle.DestroyRoomStream)
r.HandleFunc("/whip/{uuid}", handler(proxy, live777Url, live777Token))
r.HandleFunc("/whep/{uuid}", handler(proxy, live777Url, live777Token))
})

r.Post("/user/", handle.CreateUser)

//r.Post("/room/{roomId}/message", handle.CreateMessage)
//r.Get("/room/{roomId}/message", handle.ShowMessage)

r.HandleFunc("/whip/{uuid}", handler(proxy, live777Url, live777Token))
r.HandleFunc("/whep/{uuid}", handler(proxy, live777Url, live777Token))

r.Handle("/*", http.StripPrefix("/", http.FileServer(helper.NewSinglePageApp("index.html", http.FS(static.Dist)))))
return r
}
5 changes: 3 additions & 2 deletions webapp/components/use/whip.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { useSyncExternalStore } from 'react'
import { event, Context, Data } from './whxp'
import { Stream, StreamState } from '../../lib/api'
import { Stream, StreamState, token} from '../../lib/api'
import { WHIPClient } from 'whip-whep/whip'
import {
deviceNone,
Expand All @@ -9,6 +9,7 @@ import {
asyncGetVideoStream,
} from '../../lib/device'


interface WHIPData extends Data {
setUserName: (name: string) => void,
setSyncUserStatus: (callback: (userStatus: Stream) => void) => void,
Expand Down Expand Up @@ -188,7 +189,7 @@ class WHIPContext extends Context {

try {
const url = location.origin + `/whip/${id}`
await client.publish(pc, url)
await client.publish(pc, url, token)
} catch (e) {
console.log(e)
userStatus.state = StreamState.Failed
Expand Down
2 changes: 2 additions & 0 deletions webapp/lib/api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,8 @@ export {
delStream,

StreamState,

token,
}

export type {
Expand Down

0 comments on commit d4b4472

Please sign in to comment.