poll polls the synchronisation server for notifications, then dispatches them for processing.
(sid SyncSessionID)
| 449 | // poll polls the synchronisation server for notifications, then dispatches |
| 450 | // them for processing. |
| 451 | func (sc *syncClient) poll(sid SyncSessionID) { |
| 452 | for { |
| 453 | var sn SyncNotes |
| 454 | poll := sc.client.Go("SeesawSync.Poll", sid, &sn, nil) |
| 455 | select { |
| 456 | case <-poll.Done: |
| 457 | if poll.Error != nil { |
| 458 | log.Errorf("Synchronisation polling failed: %v", poll.Error) |
| 459 | return |
| 460 | } |
| 461 | for _, note := range sn.Notes { |
| 462 | sc.dispatch(¬e) |
| 463 | } |
| 464 | |
| 465 | case <-sc.quit: |
| 466 | sc.stopped <- true |
| 467 | return |
| 468 | |
| 469 | case <-time.After(syncPollTimeout): |
| 470 | log.Warningf("Synchronisation polling timed out after %s", syncPollTimeout) |
| 471 | return |
| 472 | } |
| 473 | } |
| 474 | } |
| 475 | |
| 476 | // handleNote dispatches a synchronisation note to the appropriate handler. |
| 477 | func (sc *syncClient) handleNote(note *SyncNote) { |