本文整理匯總了Golang中github.com/cubicdaiya/apns.Client.TimeoutWaitError方法的典型用法代碼示例。如果您正苦於以下問題:Golang Client.TimeoutWaitError方法的具體用法?Golang Client.TimeoutWaitError怎麽用?Golang Client.TimeoutWaitError使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類github.com/cubicdaiya/apns.Client
的用法示例。
在下文中一共展示了Client.TimeoutWaitError方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。
示例1: pushNotificationWorker
func pushNotificationWorker() {
var (
success bool
retryMax int
ep string
apnsClient *apns.Client
loop int
err error
)
if ConfGaurun.Ios.Sandbox {
ep = EpApnsSandbox
} else {
ep = EpApnsProd
}
apnsClient = nil
loop = 0
for {
stime := time.Now()
notification := <-QueueNotification
etime := time.Now()
itime := etime.Sub(stime).Seconds()
if notification.Platform == PlatFormIos {
if apnsClient != nil && int(itime) > ConfGaurun.Ios.KeepAliveIdleTimeout {
apnsClient.Conn.Close()
apnsClient.ConnTls.Close()
apnsClient = nil
}
if apnsClient != nil && ConfGaurun.Ios.KeepAliveMax > 0 && loop > ConfGaurun.Ios.KeepAliveMax {
apnsClient.Conn.Close()
apnsClient.ConnTls.Close()
apnsClient = nil
loop = 0
}
loop++
if apnsClient == nil {
apnsClient, err = apns.NewClient(
ep,
ConfGaurun.Ios.PemCertPath,
ConfGaurun.Ios.PemKeyPath,
0,
)
if err != nil {
LogError.Errorf("failed to connect to APNS: %s", err.Error())
apnsClient = nil
loop = 0
QueueNotification <- notification
continue
}
apnsClient.TimeoutWaitError = time.Duration(ConfGaurun.Ios.TimeoutError) * time.Millisecond
}
}
switch notification.Platform {
case PlatFormIos:
success = pushNotificationIos(notification, apnsClient)
if !success {
apnsClient = nil
}
retryMax = ConfGaurun.Ios.RetryMax
case PlatFormAndroid:
success = pushNotificationAndroid(notification)
retryMax = ConfGaurun.Android.RetryMax
}
if !success && notification.Retry < retryMax {
if len(QueueNotification) < cap(QueueNotification) {
notification.Retry++
QueueNotification <- notification
}
}
}
}