{"action":"created","issue":{"url":"https://api.github.com/repos/name5566/leaf/issues/117","repository_url":"https://api.github.com/repos/name5566/leaf","labels_url":"https://api.github.com/repos/name5566/leaf/issues/117/labels{/name}","comments_url":"https://api.github.com/repos/name5566/leaf/issues/117/comments","events_url":"https://api.github.com/repos/name5566/leaf/issues/117/events","html_url":"https://github.com/name5566/leaf/issues/117","id":354606750,"node_id":"MDU6SXNzdWUzNTQ2MDY3NTA=","number":117,"title":"请问一下 ws_client是怎么用的，start后没有返回链接，该怎么和服务器通讯呢？是和服务器同一个进程还是另生成一个exe？","user":{"login":"jjjjilyf","id":7004409,"node_id":"MDQ6VXNlcjcwMDQ0MDk=","avatar_url":"https://avatars0.githubusercontent.com/u/7004409?v=4","gravatar_id":"","url":"https://api.github.com/users/jjjjilyf","html_url":"https://github.com/jjjjilyf","followers_url":"https://api.github.com/users/jjjjilyf/followers","following_url":"https://api.github.com/users/jjjjilyf/following{/other_user}","gists_url":"https://api.github.com/users/jjjjilyf/gists{/gist_id}","starred_url":"https://api.github.com/users/jjjjilyf/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jjjjilyf/subscriptions","organizations_url":"https://api.github.com/users/jjjjilyf/orgs","repos_url":"https://api.github.com/users/jjjjilyf/repos","events_url":"https://api.github.com/users/jjjjilyf/events{/privacy}","received_events_url":"https://api.github.com/users/jjjjilyf/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":3,"created_at":"2018-08-28T07:34:59Z","updated_at":"2018-08-28T11:40:42Z","closed_at":null,"author_association":"NONE","body":"type WSClient struct {\r\n\tsync.Mutex\r\n\tAddr             string\r\n\tConnNum          int\r\n\tConnectInterval  time.Duration\r\n\tPendingWriteNum  int\r\n\tMaxMsgLen        uint32\r\n\tHandshakeTimeout time.Duration\r\n\tAutoReconnect    bool\r\n\tNewAgent         func(*WSConn) Agent\r\n\tdialer           websocket.Dialer\r\n\tconns            WebsocketConnSet\r\n\twg               sync.WaitGroup\r\n\tcloseFlag        bool\r\n}\r\n\r\nfunc (client *WSClient) Start() {\r\n\tclient.init()\r\n\r\n\tfor i := 0; i < client.ConnNum; i++ {\r\n\t\tclient.wg.Add(1)\r\n\t\tgo client.connect()\r\n\t}\r\n}"},"comment":{"url":"https://api.github.com/repos/name5566/leaf/issues/comments/416553114","html_url":"https://github.com/name5566/leaf/issues/117#issuecomment-416553114","issue_url":"https://api.github.com/repos/name5566/leaf/issues/117","id":416553114,"node_id":"MDEyOklzc3VlQ29tbWVudDQxNjU1MzExNA==","user":{"login":"jjjjilyf","id":7004409,"node_id":"MDQ6VXNlcjcwMDQ0MDk=","avatar_url":"https://avatars0.githubusercontent.com/u/7004409?v=4","gravatar_id":"","url":"https://api.github.com/users/jjjjilyf","html_url":"https://github.com/jjjjilyf","followers_url":"https://api.github.com/users/jjjjilyf/followers","following_url":"https://api.github.com/users/jjjjilyf/following{/other_user}","gists_url":"https://api.github.com/users/jjjjilyf/gists{/gist_id}","starred_url":"https://api.github.com/users/jjjjilyf/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jjjjilyf/subscriptions","organizations_url":"https://api.github.com/users/jjjjilyf/orgs","repos_url":"https://api.github.com/users/jjjjilyf/repos","events_url":"https://api.github.com/users/jjjjilyf/events{/privacy}","received_events_url":"https://api.github.com/users/jjjjilyf/received_events","type":"User","site_admin":false},"created_at":"2018-08-28T11:40:42Z","updated_at":"2018-08-28T11:40:42Z","author_association":"NONE","body":"\r\ntype WSClient struct {\r\n\tsync.Mutex\r\n\tAddr             string\r\n\tConnNum          int\r\n\tConnectInterval  time.Duration\r\n\tPendingWriteNum  int\r\n\tMaxMsgLen        uint32\r\n\tHandshakeTimeout time.Duration\r\n\tAutoReconnect    bool\r\n\tNewAgent         func(*WSConn) Agent\r\n\tdialer           websocket.Dialer\r\n\tconns            WebsocketConnSet\r\n\twg               sync.WaitGroup\r\n\tcloseFlag        bool\r\n\t**Conns \t\t\t[]*WSConn**\r\n}\r\n\r\nfunc (client *WSClient) connect() {\r\n\tdefer client.wg.Done()\r\n\t**log.Debug(\"1\")**\r\nreconnect:\r\n\t**log.Debug(\"2\")**\r\n\tconn := client.dial()\r\n\tif conn == nil {\r\n\t\treturn\r\n\t}\r\n\t**log.Debug(\"3\")**\r\n\tconn.SetReadLimit(int64(client.MaxMsgLen))\r\n\r\n\tclient.Lock()\r\n\tif client.closeFlag {\r\n\t\tclient.Unlock()\r\n\t\tconn.Close()\r\n\t\treturn\r\n\t}\r\n\tclient.conns[conn] = struct{}{}\r\n\tclient.Unlock()\r\n\r\n\twsConn := newWSConn(conn, client.PendingWriteNum, client.MaxMsgLen)\r\n\t**client.Conns = append(client.Conns, wsConn)**\r\n\tagent := client.NewAgent(wsConn)\r\n\tagent.Run()\r\n\r\n\r\nConnect执行不下去，只能打印到2，不会打印到3，一个都创建不成功，连的地址就是“127.0.0.1:80”,请问是不是还需要别的参数？\r\n\r\n\tc := &network.WSClient{\r\n\t\t**Addr:\t\"ws://localhost:80\",**\r\n\t\tConnNum: 10,\r\n\t\tNewAgent:func(conn * network.WSConn) network.Agent{\r\n\t\t\ta := &agent{conn: conn}\r\n\t\t\treturn a\r\n\t\t},\r\n\t}\r\n\r\n\tc.Start()\r\n\r\n\r\n\tbuilder := flatbuffers.NewBuilder(0)\r\n\r\n\tfor i, con := range c.Conns {\r\n\t\t<-time.After(time.Duration(util.RandInterval(500, 3000)))\r\n\t\t// 登录\r\n\t\tstrOff := builder.CreateString(strconv.Itoa(i+1))\r\n\t\tmsg.LoginOpenIDCheckREQStart(builder)\r\n\t\tmsg.LoginOpenIDCheckREQAddOpenID(builder, strOff)\r\n\t\tmOff := msg.LoginOpenIDCheckREQEnd(builder)\r\n\t\tbuilder.Finish(mOff)\r\n\t\tbuf := builder.FinishedBytes()\r\n\t\tdata := assambleFB(12, buf)\r\n\t\tbuilder.Reset()\r\n\t\tcon.WriteMsg(data...)\r\n\t}"}}
{"actor":{"display_login":"jjjjilyf"}}