NewClient returns a pointer to a new Client. The returned instance is not connected. You have to call Dial() or DialForever() before calling Tell() and Go() methods.
(remoteURL string)
| 201 | // is not connected. You have to call Dial() or DialForever() before calling |
| 202 | // Tell() and Go() methods. |
| 203 | func (k *Kite) NewClient(remoteURL string) *Client { |
| 204 | c := &Client{ |
| 205 | LocalKite: k, |
| 206 | URL: remoteURL, |
| 207 | disconnect: make(chan struct{}), |
| 208 | closeChan: make(chan struct{}), |
| 209 | redialBackOff: forever, |
| 210 | scrubber: dnode.NewScrubber(), |
| 211 | testHookSetSession: nopSetSession, |
| 212 | Concurrent: true, |
| 213 | send: make(chan *message), |
| 214 | interrupt: make(chan error, 1), |
| 215 | ctx: context.Background(), |
| 216 | cancel: func() {}, |
| 217 | } |
| 218 | |
| 219 | c.OnConnect(c.setContext) |
| 220 | c.OnDisconnect(c.closeContext) |
| 221 | |
| 222 | k.OnRegister(c.updateAuth) |
| 223 | |
| 224 | return c |
| 225 | } |
| 226 | |
| 227 | func (c *Client) SetUsername(username string) { |
| 228 | c.muProt.Lock() |