|
@@ -16,22 +16,26 @@ type WsClient struct {
|
|
|
pos int // 指示当前连接第几个 addr
|
|
pos int // 指示当前连接第几个 addr
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
-func NewWsClient(cf *nnet.HubConfig, cb nnet.ISessionCallback, p nnet.IProtocol, addr string) *WsClient {
|
|
|
|
|
|
|
+func NewWsClient(cf *nnet.HubConfig, cb nnet.ISessionCallback, p nnet.IProtocol) *WsClient {
|
|
|
return &WsClient{
|
|
return &WsClient{
|
|
|
Hub: newHub(cf, cb, p),
|
|
Hub: newHub(cf, cb, p),
|
|
|
- addr: addr,
|
|
|
|
|
pos: 0,
|
|
pos: 0,
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
func (self *WsClient) Start() error {
|
|
func (self *WsClient) Start() error {
|
|
|
- conn, _, err := websocket.DefaultDialer.Dial(self.addr, nil)
|
|
|
|
|
|
|
+ return nil
|
|
|
|
|
+}
|
|
|
|
|
+
|
|
|
|
|
+func (self *WsClient)NewConnection(addr string, id uint64) error {
|
|
|
|
|
+ conn, _, err := websocket.DefaultDialer.Dial(addr, nil)
|
|
|
if err != nil {
|
|
if err != nil {
|
|
|
return err
|
|
return err
|
|
|
}
|
|
}
|
|
|
self.wg.Add(1)
|
|
self.wg.Add(1)
|
|
|
go func() {
|
|
go func() {
|
|
|
ses := newSession(NewWsConn(conn), self)
|
|
ses := newSession(NewWsConn(conn), self)
|
|
|
|
|
+ ses.UpdateId(id)
|
|
|
ses.Do()
|
|
ses.Do()
|
|
|
self.wg.Done()
|
|
self.wg.Done()
|
|
|
}()
|
|
}()
|