Start creates the goroutines for sending and receiving of messages. It must be called once after creating a connection. It should only be called once, subsequent calls will have no effect.
()
| 270 | // be called once after creating a connection. It should only be called once, |
| 271 | // subsequent calls will have no effect. |
| 272 | func (c *rawConnection) Start() { |
| 273 | c.startStopMut.Lock() |
| 274 | defer c.startStopMut.Unlock() |
| 275 | |
| 276 | select { |
| 277 | case <-c.started: |
| 278 | return |
| 279 | case <-c.closed: |
| 280 | // we have already closed the connection before starting processing |
| 281 | // on it. |
| 282 | return |
| 283 | default: |
| 284 | } |
| 285 | |
| 286 | c.loopWG.Add(5) |
| 287 | go func() { |
| 288 | c.readerLoop() |
| 289 | c.loopWG.Done() |
| 290 | }() |
| 291 | go func() { |
| 292 | err := c.dispatcherLoop() |
| 293 | c.Close(err) |
| 294 | c.loopWG.Done() |
| 295 | }() |
| 296 | go func() { |
| 297 | c.writerLoop() |
| 298 | c.loopWG.Done() |
| 299 | }() |
| 300 | go func() { |
| 301 | c.pingSender() |
| 302 | c.loopWG.Done() |
| 303 | }() |
| 304 | go func() { |
| 305 | c.pingReceiver() |
| 306 | c.loopWG.Done() |
| 307 | }() |
| 308 | |
| 309 | c.startTime = time.Now().Truncate(time.Second) |
| 310 | close(c.started) |
| 311 | } |
| 312 | |
| 313 | func (c *rawConnection) DeviceID() DeviceID { |
| 314 | return c.deviceID |
nothing calls this directly
no test coverage detected