|
@@ -4,7 +4,6 @@ import (
|
|
"testing"
|
|
"testing"
|
|
"time"
|
|
"time"
|
|
|
|
|
|
- "git.ali33.ru/fcg-xvii/go-tools/json"
|
|
|
|
"git.ali33.ru/fcg-xvii/rest"
|
|
"git.ali33.ru/fcg-xvii/rest"
|
|
"git.ali33.ru/fcg-xvii/rest/example_chat/chat"
|
|
"git.ali33.ru/fcg-xvii/rest/example_chat/chat"
|
|
ws "git.ali33.ru/fcg-xvii/rest/rest_websocket"
|
|
ws "git.ali33.ru/fcg-xvii/rest/rest_websocket"
|
|
@@ -12,8 +11,7 @@ import (
|
|
|
|
|
|
func TestChat(t *testing.T) {
|
|
func TestChat(t *testing.T) {
|
|
|
|
|
|
- addr := "127.0.0.1:40000"
|
|
|
|
- clAddr := "ws://127.0.0.1:40000/ws"
|
|
|
|
|
|
+ addr := "192.168.88.27:40000"
|
|
|
|
|
|
core := chat.New()
|
|
core := chat.New()
|
|
|
|
|
|
@@ -27,54 +25,47 @@ func TestChat(t *testing.T) {
|
|
restEngine := ws.New(app, core)
|
|
restEngine := ws.New(app, core)
|
|
restEngine.Prepare(server, "/ws")
|
|
restEngine.Prepare(server, "/ws")
|
|
|
|
|
|
|
|
+ ch := make(chan struct{})
|
|
|
|
+ <-ch
|
|
|
|
+
|
|
//ch := make(chan struct{})
|
|
//ch := make(chan struct{})
|
|
//<-ch
|
|
//<-ch
|
|
|
|
|
|
- cl, err := ws.NewClient(clAddr)
|
|
|
|
- if err != nil {
|
|
|
|
- t.Fatal(err)
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- t.Log(cl)
|
|
|
|
-
|
|
|
|
/*
|
|
/*
|
|
- mes := rest_websocket.(
|
|
|
|
- "/users/register",
|
|
|
|
- json.Map{
|
|
|
|
- "name": "LETO",
|
|
|
|
- "password": "my-pass-99",
|
|
|
|
|
|
+ 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",
|
|
|
|
+ },
|
|
},
|
|
},
|
|
- nil,
|
|
|
|
- time.Second*10,
|
|
|
|
- rest.RequestTypeMessage,
|
|
|
|
- )
|
|
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ 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()
|
|
*/
|
|
*/
|
|
|
|
|
|
- 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()
|
|
|
|
- time.Sleep(time.Second * 60)
|
|
|
|
}
|
|
}
|