package cpn import ( "github.com/gorilla/websocket" "one.com/nnet" ) // type WsClient struct { *Hub addr string pos int // } func NewWsClient(cf *nnet.HubConfig, cb nnet.ISessionCallback, p nnet.IProtocol) nnet.IHub { return &WsClient{ Hub: newHub(cf, cb, p), pos: 0, } } func (self *WsClient) NewConnection(addr string, id uint64) error { conn, _, err := websocket.DefaultDialer.Dial(addr, nil) if err != nil { return err } self.wg.Add(1) go func() { ses := newSession(NewWsConn(conn), self) ses.UpdateId(id) ses.Do() self.wg.Done() }() return nil }