package fusenrender_test import ( "encoding/json" "fmt" "fusenrender" "io" "log" "net/http" "testing" "time" "github.com/474420502/requests" ) func TestWebsocketA(t *testing.T) { svc, err := fusenrender.LoadConfig("etc/etc_a.yaml") if err != nil { panic(err) } fusenrender.StartNode(svc) } func TestWebsocketB(t *testing.T) { svc, err := fusenrender.LoadConfig("etc/etc_b.yaml") if err != nil { panic(err) } fusenrender.StartNode(svc) } func TestWebsocketC(t *testing.T) { svc, err := fusenrender.LoadConfig("etc/etc_c.yaml") if err != nil { panic(err) } fusenrender.StartNode(svc) } var addr = "api.fusen.3718.cn:4050" // var addr = "localhost:4050" func TestWebsocketCient(t *testing.T) { // u := url.URL{Scheme: "ws", Host: addr, Path: "/ws/pop/queue"} // conn, _, err := websocket.DefaultDialer.Dial(u.String(), nil) // log.Println(err) // defer conn.Close() var m any err := json.Unmarshal([]byte(sendjson), &m) if err != nil { panic(err) } go func() { C := time.NewTicker(time.Second * 5) for range C.C { item := fusenrender.QueueItem{ Group: "unity3d", CreateAt: time.Now(), Data: m, } r, err := requests.Post(fmt.Sprintf("http://%s/api/render/queue/push", addr)).SetBodyJson(item).Execute() log.Println(r, err) } }() select {} // for { // // err = conn.WriteMessage(websocket.PingMessage, nil) // // log.Println("write ping") // // if err != nil { // // log.Println(err) // // return // // } // mt, msg, err := conn.ReadMessage() // fmt.Println(mt, err) // if mt == websocket.CloseMessage { // return // } // fmt.Printf("Received: %s\n", string(msg)) // } } func TestCallback(t *testing.T) { http.HandleFunc("/api/render/render_notify", func(w http.ResponseWriter, r *http.Request) { data, _ := io.ReadAll(r.Body) log.Println(string(data)) }) log.Println(fmt.Sprintf(":%d", 4444)) http.ListenAndServe(fmt.Sprintf(":%d", 4444), nil) }