添加视频流接口

This commit is contained in:
junleea 2024-12-26 13:36:51 +08:00
parent 0f37e738a7
commit 586356c18a
1 changed files with 2 additions and 1 deletions

View File

@ -8,6 +8,7 @@ import (
"github.com/gin-gonic/gin" "github.com/gin-gonic/gin"
"github.com/google/uuid" "github.com/google/uuid"
"github.com/gorilla/websocket" "github.com/gorilla/websocket"
"io"
"net/http" "net/http"
"strconv" "strconv"
"time" "time"
@ -360,7 +361,7 @@ func VideoFeed(c *gin.Context) {
// 创建一个通道用于接收客户端连接关闭的信号 // 创建一个通道用于接收客户端连接关闭的信号
clientClosed := make(chan struct{}) clientClosed := make(chan struct{})
c.Stream(func(w http.ResponseWriter) bool { c.Stream(func(w io.Writer) bool {
// 将读取 Redis 消息通道的逻辑放在这里,方便根据返回值控制循环 // 将读取 Redis 消息通道的逻辑放在这里,方便根据返回值控制循环
ch := pubSub.Channel() ch := pubSub.Channel()
for { for {