common

package
v0.0.0-...-0805cb3 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 9, 2020 License: Apache-2.0 Imports: 1 Imported by: 0

Documentation

Overview

Package common contains common interfaces and data types for abstractions of apns request/response push protocols.

Index

Constants

View Source
const (
	Status0Success            = 0
	Status1ProcessingError    = 1
	Status2MissingDeviceToken = 2
	Status3MissingTopic       = 3
	Status4MissingPayload     = 4
	Status5InvalidTokenSize   = 5
	Status6InvalidTopicSize   = 6
	Status7InvalidPayloadSize = 7
	Status8Unsubscribe        = 8
)

Status codes for the binary API

Variables

This section is empty.

Functions

This section is empty.

Types

type APNSResult

type APNSResult struct {
	// MsgID is a unique identifier for the given push attempt to APNs (it is unique within a reasonable time window).
	// This is used by the binary API to associate asynchronous errors with the push request.
	MsgID uint32
	// Status is a status code for the binary API. The HTTP/2 errors are also translated to those status codes.
	Status uint8
	// Err will be handled by the error handler for APNs differently based on the type implementing this interface.
	Err push.Error
}

APNSResult represents the response from the push request to APNs (either from the binary API or HTTP/2)

type PushRequest

type PushRequest struct {
	PSP       *push.PushServiceProvider
	Devtokens [][]byte
	Payload   []byte
	MaxMsgID  uint32
	Expiry    uint32

	// DPList is a list of delivery points of the same length as Devtokens. DPList[i].FixedData["dev_token"] == string(Devtokens[i])
	DPList  []*push.DeliveryPoint
	ErrChan chan<- push.Error
	ResChan chan<- *APNSResult
}

PushRequest contains the data needed for an push attempt to APNs for the given list of delivery points (for both HTTP/2 and binary APIs).

func (*PushRequest) GetID

func (request *PushRequest) GetID(idx int) uint32

GetID determines the message id associated with a given dev token's index. This is used by the binary protocol.

type PushRequestProcessor

type PushRequestProcessor interface {
	// AddRequest adds a push request, and asynchronously processes it.
	// The APNSRequestProcessor will first add errors it encountered sending to add responses and errors to the respective channels and close channels.
	AddRequest(request *PushRequest)

	// GetMaxPayloadSize returns the maximum JSON payload for this protocol.
	GetMaxPayloadSize() int

	// Finalize() will close any connections, waiting for them to finish closing before returning.
	Finalize()

	// SetErrorReportChan sets the error reporting channel (shared with the apnsPushService)
	SetErrorReportChan(errChan chan<- push.Error)

	// SetPushServiceConfig sets the config of this PushRequestProcessor when the service is registered.
	SetPushServiceConfig(c *push.PushServiceConfig)
}

PushRequestProcessor abstracts the different network protocols Apple has for sending push notifications.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL