Compare commits

..

No commits in common. "d4281c3265518f03c3482fb28425c39cba1ea29f" and "e71790d80d3068a0e4fe20f63a82917bfdb53dd2" have entirely different histories.

2 changed files with 9 additions and 82 deletions

View File

@ -3,15 +3,13 @@ package controllers
import (
"bytes"
"encoding/json"
"fmt"
"github.com/gin-gonic/gin"
"io"
"net/http"
"time"
"github.com/gin-gonic/gin"
"sourcecode.social/greatape/goldgorilla/models"
"sourcecode.social/greatape/goldgorilla/models/dto"
"sourcecode.social/greatape/goldgorilla/repositories"
"time"
)
type RoomController struct {
@ -45,91 +43,20 @@ func (c *RoomController) CreatePeer(ctx *gin.Context) {
c.helper.Response(ctx, struct{}{}, http.StatusNoContent)
}
func (c *RoomController) RetryAddICECandidate(ctx *gin.Context, tries int) {
time.Sleep(1 * time.Second)
tries++
fmt.Println("----RetryAddICECandidate----")
func (c *RoomController) AddICECandidate(ctx *gin.Context) {
var reqModel dto.AddPeerICECandidateReqModel
badReqSt := 400
err1 := ctx.ShouldBindJSON(&reqModel)
// if err1 != nil && tries < 3 {
// // var reqGlobal interface{}
// // err2 := ctx.ShouldBindJSON(&reqGlobal)
// // fmt.Println("Err2: ", err2)
// // fmt.Println("reqGlobal: ", reqGlobal)
// c.RetryAddICECandidate(ctx, tries)
// return
// }
if err1 != nil {
c.helper.HandleIfErr(ctx, err1, &badReqSt)
fmt.Println("Err1: ", err1)
if err := ctx.ShouldBindJSON(&reqModel); c.helper.HandleIfErr(ctx, err, &badReqSt) {
return
}
// if err := ctx.ShouldBindJSON(&reqModel); c.helper.HandleIfErr(ctx, err, &badReqSt) {
// fmt.Println("Err1: ", err)
// time.Sleep(1 * time.Second)
// c.RetryAddICECandidate(ctx, tries)
// return
// }
if !reqModel.Validate() {
c.helper.ResponseUnprocessableEntity(ctx)
fmt.Println("Validate")
return
}
err := c.repo.AddPeerIceCandidate(reqModel.RoomId, reqModel.ID, reqModel.ICECandidate)
if err != nil && tries < 3 {
c.RetryAddICECandidate(ctx, tries)
if c.helper.HandleIfErr(ctx, err, nil) {
return
}
if err != nil {
c.helper.HandleIfErr(ctx, err, &badReqSt)
fmt.Println("Err: ", err)
return
}
// if c.helper.HandleIfErr(ctx, err, nil) {
// fmt.Println("Err2: ", err)
// time.Sleep(1 * time.Second)
// c.RetryAddICECandidate(ctx, tries)
// return
// }
c.helper.Response(ctx, struct{}{}, http.StatusNoContent)
}
func (c *RoomController) AddICECandidate(ctx *gin.Context) {
fmt.Println("----AddICECandidate----")
// bd, _ := io.ReadAll(ctx.Request.Body)
// fmt.Println("bd: ", string(bd))
var reqModel dto.AddPeerICECandidateReqModel
// badReqSt := 400
err1 := ctx.ShouldBindJSON(&reqModel)
if err1 != nil {
// c.RetryAddICECandidate(ctx, 0)
return
}
// if err := ctx.ShouldBindJSON(&reqModel); c.helper.HandleIfErr(ctx, err, &badReqSt) {
// fmt.Println("Err1: ", err)
// time.Sleep(1 * time.Second)
// c.AddICECandidate(ctx)
// return
// }
if !reqModel.Validate() {
c.helper.ResponseUnprocessableEntity(ctx)
fmt.Println("Validate")
return
}
err := c.repo.AddPeerIceCandidate(reqModel.RoomId, reqModel.ID, reqModel.ICECandidate)
if err != nil {
c.RetryAddICECandidate(ctx, 0)
return
}
// if c.helper.HandleIfErr(ctx, err, nil) {
// fmt.Println("Err2: ", err)
// time.Sleep(1 * time.Second)
// c.AddICECandidate(ctx)
// return
// }
c.helper.Response(ctx, struct{}{}, http.StatusNoContent)
}

View File

@ -6,10 +6,10 @@ import (
)
func main() {
svcAddr := flag.String("svc-addr", "http://localhost:8080", "service baseurl to register in logjam ( shouldn't end with / )")
src := flag.String("src", "localhost:8080", "listenHost:listenPort")
logjamBaseUrl := flag.String("logjam-base-url", "http://localhost:8090", "logjam base url(shouldn't end with /)")
targetRoom := flag.String("targetRoom", "test-room", "target room")
svcAddr := flag.String("svc-addr", "", "service baseurl to register in logjam ( shoudln't end with / )")
src := flag.String("src", ":8080", "listenhost:listenPort")
logjamBaseUrl := flag.String("logjam-base-url", "https://example.com", "logjam base url(shouldn't end with /)")
targetRoom := flag.String("targetRoom", "testyroom", "target room")
flag.Parse()