bugfix
parent
9c3dcdb012
commit
3869c5f2be
|
|
@ -4,13 +4,30 @@ import (
|
||||||
"api/database"
|
"api/database"
|
||||||
"api/models"
|
"api/models"
|
||||||
"api/utils"
|
"api/utils"
|
||||||
|
"bytes"
|
||||||
|
"encoding/json"
|
||||||
"fmt"
|
"fmt"
|
||||||
"log"
|
"log"
|
||||||
|
"net/http"
|
||||||
"strconv"
|
"strconv"
|
||||||
|
|
||||||
"github.com/gofiber/fiber/v2"
|
"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 {
|
func ServerStart(c *fiber.Ctx) error {
|
||||||
// Creates a server struct
|
// Creates a server struct
|
||||||
s := new(models.LalServer)
|
s := new(models.LalServer)
|
||||||
|
|
@ -86,7 +103,10 @@ func OnPubStart(c *fiber.Ctx) error {
|
||||||
if err := c.BodyParser(p); err != nil {
|
if err := c.BodyParser(p); err != nil {
|
||||||
return err
|
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()))
|
return c.SendString("On_Pub_Start: " + string(c.Body()))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -12,14 +12,18 @@ type LalServer struct {
|
||||||
|
|
||||||
type Pub struct {
|
type Pub struct {
|
||||||
Server string `json:"server_id"`
|
Server string `json:"server_id"`
|
||||||
|
SessionId string `json:"session_id"`
|
||||||
Protocol string `json:"protocol"`
|
Protocol string `json:"protocol"`
|
||||||
|
BaseType string `json:"base_type"`
|
||||||
|
RemoteAddress string `json:"remotet_addr"`
|
||||||
Url string `json:"url"`
|
Url string `json:"url"`
|
||||||
AppName string `json:"app_name"`
|
AppName string `json:"app_name"`
|
||||||
Channel string `json:"stream_name"`
|
Channel string `json:"stream_name"`
|
||||||
UrlParam string `json:"url_param"`
|
UrlParam string `json:"url_param"`
|
||||||
RemoteAddress string `json:"remotet_addr"`
|
|
||||||
HasInSession bool `json:"has_in_session"`
|
HasInSession bool `json:"has_in_session"`
|
||||||
HasOutSession bool `json:"has_out_session"`
|
HasOutSession bool `json:"has_out_session"`
|
||||||
|
ReadBytesSum bool `json:"read_bytes_sum"`
|
||||||
|
WroteBytesSum bool `json:"wrote_bytes_sum"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type Update struct {
|
type Update struct {
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue