~jonas-drange/ubuntu-push/lp1577723-skiptest

« back to all changes in this revision

Viewing changes to client/client.go

  • Committer: John R. Lenton
  • Date: 2014-08-21 10:47:12 UTC
  • mto: This revision was merged to the branch mainline in revision 315.
  • Revision ID: jlenton@gmail.com-20140821104712-7i03q9eqotfdadzu
poller

Show diffs side-by-side

added added

removed removed

Lines of Context:
44
44
        "launchpad.net/ubuntu-push/identifier"
45
45
        "launchpad.net/ubuntu-push/launch_helper"
46
46
        "launchpad.net/ubuntu-push/logger"
 
47
        "launchpad.net/ubuntu-push/poller"
47
48
        "launchpad.net/ubuntu-push/protocol"
48
49
        "launchpad.net/ubuntu-push/util"
49
50
)
71
72
        // fallback values for simplified notification usage
72
73
        FallbackVibration *launch_helper.Vibration `json:"fallback_vibration"`
73
74
        FallbackSound     string                   `json:"fallback_sound"`
 
75
        // times for the poller
 
76
        PollInterval    config.ConfigTimeDuration `json:"poll_interval"`
 
77
        PollSettle      config.ConfigTimeDuration `json:"poll_settle"`
 
78
        PollNetworkWait config.ConfigTimeDuration `json:"poll_net_wait"`
 
79
        PollPolldWait   config.ConfigTimeDuration `json:"poll_polld_wait"`
 
80
        PollDoneWait    config.ConfigTimeDuration `json:"poll_done_wait"`
74
81
}
75
82
 
76
83
// PushService is the interface we use of service.PushService.
221
228
        }
222
229
}
223
230
 
 
231
// derivePollerSetup derives the Poller setup from the client configuration bits.
 
232
func (client *PushClient) derivePollerSetup() *poller.PollerSetup {
 
233
        return &poller.PollerSetup{
 
234
                Times: poller.Times{
 
235
                        AlarmInterval:      client.config.PollInterval.TimeDuration(),
 
236
                        SessionStateSettle: client.config.PollSettle.TimeDuration(),
 
237
                        NetworkWait:        client.config.PollNetworkWait.TimeDuration(),
 
238
                        PolldWait:          client.config.PollPolldWait.TimeDuration(),
 
239
                        DoneWait:           client.config.PollDoneWait.TimeDuration(),
 
240
                },
 
241
                Log:                client.log,
 
242
                SessionStateGetter: client.session,
 
243
        }
 
244
}
 
245
 
224
246
// getAuthorization gets the authorization blob to send to the server
225
247
func (client *PushClient) getAuthorization(url string) string {
226
248
        client.log.Debugf("getting authorization for %s", url)
280
302
                return err
281
303
        }
282
304
        client.session = sess
 
305
        p := poller.New(client.derivePollerSetup())
 
306
        if err := p.Start(); err != nil {
 
307
                return err
 
308
        }
 
309
        if err := p.Run(); err != nil {
 
310
                return err
 
311
        }
283
312
        return nil
284
313
}
285
314