main
nilo 2024-11-06 20:59:49 -03:00
parent 9c3dcdb012
commit 3869c5f2be
2 changed files with 26 additions and 2 deletions

View File

@ -4,13 +4,30 @@ import (
"api/database"
"api/models"
"api/utils"
"bytes"
"encoding/json"
"fmt"
"log"
"net/http"
"strconv"
"github.com/gofiber/fiber/v2"
)
func KickSession(strean_name, session_id string) {
url := "localhost:8083/api/ctrl/kick_session"
values := map[string]string{"stream_name": strean_name, "session_id": session_id}
jsonValue, _ := json.Marshal(values)
_, err := http.Post(url, "application/json", bytes.NewBuffer(jsonValue))
if err != nil {
panic(err)
}
}
func ServerStart(c *fiber.Ctx) error {
// Creates a server struct
s := new(models.LalServer)
@ -86,7 +103,10 @@ func OnPubStart(c *fiber.Ctx) error {
if err := c.BodyParser(p); err != nil {
return err
}
log.Printf("Start channel %s, urlParam %s, AppName %s\n", p.Channel, p.UrlParam, p.AppName)
log.Printf("Start channel %s, urlParam %s, SessionId %s\n", p.Channel, p.UrlParam, p.SessionId)
KickSession(p.Channel, p.SessionId)
return c.SendString("On_Pub_Start: " + string(c.Body()))
}

View File

@ -12,14 +12,18 @@ type LalServer struct {
type Pub struct {
Server string `json:"server_id"`
SessionId string `json:"session_id"`
Protocol string `json:"protocol"`
BaseType string `json:"base_type"`
RemoteAddress string `json:"remotet_addr"`
Url string `json:"url"`
AppName string `json:"app_name"`
Channel string `json:"stream_name"`
UrlParam string `json:"url_param"`
RemoteAddress string `json:"remotet_addr"`
HasInSession bool `json:"has_in_session"`
HasOutSession bool `json:"has_out_session"`
ReadBytesSum bool `json:"read_bytes_sum"`
WroteBytesSum bool `json:"wrote_bytes_sum"`
}
type Update struct {