1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071 |
- 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()
- */
- }
|