push

package
v0.16.2-rc2 Latest Latest
Warning

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

Go to latest
Published: Oct 14, 2019 License: GPL-3.0 Imports: 4 Imported by: 21

Documentation

Overview

Package push contains interfaces to be implemented by push notification plugins.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Init

func Init(jsconfig string) error

Init initializes registered handlers.

func Push

func Push(msg *Receipt)

Push a single message

func Register

func Register(name string, hnd Handler)

Register a push handler

func Stop

func Stop()

Stop all pushes

Types

type Handler added in v0.14.2

type Handler interface {
	// Init initializes the handler.
	Init(jsonconf string) error

	// IsReady сheckы if the handler is initialized.
	IsReady() bool

	// Push returns a channel that the server will use to send messages to.
	// The message will be dropped if the channel blocks.
	Push() chan<- *Receipt

	// Stop terminates the handler's worker and stops sending pushes.
	Stop()
}

Handler is an interface which must be implemented by handlers.

type Payload

type Payload struct {
	// Topic which received the message.
	Topic string `json:"topic"`
	// Message sender 'usrXXX'
	From string `json:"from"`
	// Timestapm of the message.
	Timestamp time.Time `json:"ts"`
	// Sequential ID of the message.
	SeqId int `json:"seq"`
	// MIME-Type of the message content, text/x-drafty or text/plain
	ContentType string `json:"mime"`
	// Actual Data.Content of the message, if requested
	Content interface{} `json:"content,omitempty"`
}

Payload is content of the push.

type Receipt

type Receipt struct {
	// List of recipients, including those who did not receive the message
	To map[t.Uid]Recipient `json:"to"`
	// Actual content to be delivered to the client
	Payload Payload `json:"payload"`
}

Receipt is the push payload with a list of recipients.

type Recipient added in v0.14.2

type Recipient struct {
	// Count of user's connections that were live when the packet was dispatched from the server
	Delivered int `json:"delivered"`
	// List of user's devices that the packet was delivered to (if known). Len(Devices) >= Delivered
	Devices []string `json:"devices,omitempty"`
	// Unread count to include in the push
	Unread int `json:"unread"`
}

Recipient is a user targeted by the push.

Directories

Path Synopsis
Package fcm implements push notification plugin for Google FCM backend.
Package fcm implements push notification plugin for Google FCM backend.

Jump to

Keyboard shortcuts

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