package example_chat_test import ( "testing" "time" "git.ali33.ru/fcg-xvii/rest" "git.ali33.ru/fcg-xvii/rest/example_chat/chat" ws "git.ali33.ru/fcg-xvii/rest/rest_websocket" ) func TestChat(t *testing.T) { addr := "192.168.88.27:40000" core := chat.New() server := rest.NewServer(addr, []byte("top-secret")) if err := server.Listen(time.Second); err != nil { t.Fatal(err) } app := NewApplication(core) restEngine := ws.New(app, core) restEngine.Prepare(server, "/ws") ch := make(chan struct{}) <-ch //ch := make(chan struct{}) //<-ch /* clAddr := "ws://127.0.0.1:40000/ws" cl, err := ws.NewClient(clAddr) if err != nil { t.Fatal(err) } t.Log(cl) mes := &rest.RequestStream{ Timeout: time.Now().Add(time.Second), Request: &rest.Request{ Type: rest.RequestTypeIn, Command: "/users/register", Data: json.Map{ "name": "LETO", "password": "my-pass-99", }, }, } answ, err := cl.SendMessage(mes) if err != nil { t.Fatal(err) } resp, ok := <-answ if !ok { t.Log("answer is not received") } else { t.Log("resp", resp.Data) } time.Sleep(time.Second * 5) cl.Close() */ }