server

package
v5.9.0+incompatible Latest Latest
Warning

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

Go to latest
Published: May 2, 2019 License: Apache-2.0 Imports: 21 Imported by: 0

Documentation

Index

Constants

View Source
const (
	PUSH_NOTIFY_APPLE   = "apple"
	PUSH_NOTIFY_ANDROID = "android"
	PUSH_TYPE_MESSAGE   = "message"
	PUSH_TYPE_CLEAR     = "clear"
)
View Source
const (
	PUSH_STATUS           = "status"
	PUSH_STATUS_OK        = "OK"
	PUSH_STATUS_FAIL      = "FAIL"
	PUSH_STATUS_REMOVE    = "REMOVE"
	PUSH_STATUS_ERROR_MSG = "error"
)
View Source
const (
	HEADER_FORWARDED           = "X-Forwarded-For"
	HEADER_REAL_IP             = "X-Real-IP"
	WAIT_FOR_SERVER_SHUTDOWN   = time.Second * 5
	CONNECTION_TIMEOUT_SECONDS = 60
)

Variables

View Source
var MetricsEnabled bool

Functions

func FindConfigFile

func FindConfigFile(fileName string) string

func GetIpAddress

func GetIpAddress(r *http.Request) string

func LoadConfig

func LoadConfig(fileName string)

func Log

func Log(level string, msg string)

func LogCritical

func LogCritical(msg string)

func LogInfo

func LogInfo(msg string)

func NewPrometheusHandler

func NewPrometheusHandler() http.Handler

func Start

func Start()

func Stop

func Stop()

Types

type AndroidNotificationServer

type AndroidNotificationServer struct {
	AndroidPushSettings AndroidPushSettings
}

func (*AndroidNotificationServer) Initialize

func (me *AndroidNotificationServer) Initialize() bool

func (*AndroidNotificationServer) SendNotification

func (me *AndroidNotificationServer) SendNotification(msg *PushNotification) PushResponse

type AndroidPushSettings

type AndroidPushSettings struct {
	Type          string
	AndroidApiKey string
}

type AppleNotificationServer

type AppleNotificationServer struct {
	ApplePushSettings ApplePushSettings
	AppleClient       *apns.Client
}

func (*AppleNotificationServer) Initialize

func (me *AppleNotificationServer) Initialize() bool

func (*AppleNotificationServer) SendNotification

func (me *AppleNotificationServer) SendNotification(msg *PushNotification) PushResponse

type ApplePushSettings

type ApplePushSettings struct {
	Type                    string
	ApplePushUseDevelopment bool
	ApplePushCertPrivate    string
	ApplePushCertPassword   string
	ApplePushTopic          string
}

type ConfigPushProxy

type ConfigPushProxy struct {
	ListenAddress           string
	ThrottlePerSec          int
	ThrottleMemoryStoreSize int
	ThrottleVaryByHeader    string
	EnableMetrics           bool
	ApplePushSettings       []ApplePushSettings
	AndroidPushSettings     []AndroidPushSettings
}

type NotificationServer

type NotificationServer interface {
	SendNotification(msg *PushNotification) PushResponse
	Initialize() bool
}

func NewAndroideNotificationServer

func NewAndroideNotificationServer(settings AndroidPushSettings) NotificationServer

func NewAppleNotificationServer

func NewAppleNotificationServer(settings ApplePushSettings) NotificationServer

type PushNotification

type PushNotification struct {
	Id               string `json:"id"`
	AckId            string `json:"ack_id"`
	Platform         string `json:"platform"`
	ServerId         string `json:"server_id"`
	DeviceId         string `json:"device_id"`
	Category         string `json:"category"`
	Sound            string `json:"sound"`
	Message          string `json:"message"`
	Badge            int    `json:"badge"`
	ContentAvailable int    `json:"cont_ava"`
	TeamId           string `json:"team_id"`
	ChannelId        string `json:"channel_id"`
	PostId           string `json:"post_id"`
	RootId           string `json:"root_id"`
	ChannelName      string `json:"channel_name"`
	Type             string `json:"type"`
	SenderName       string `json:"sender_name"`
	SenderId         string `json:"sender_id"`
	OverrideUsername string `json:"override_username"`
	OverrideIconUrl  string `json:"override_icon_url"`
	FromWebhook      string `json:"from_webhook"`
	Version          string `json:"version"`
}

func PushNotificationFromJson

func PushNotificationFromJson(data io.Reader) *PushNotification

func (*PushNotification) ToJson

func (me *PushNotification) ToJson() string

type PushNotificationAck

type PushNotificationAck struct {
	Id       string `json:"id"`
	Platform string `json:"platform"`
	Type     string `json:"type"`
}

func PushNotificationAckFromJson

func PushNotificationAckFromJson(data io.Reader) *PushNotificationAck

func (*PushNotificationAck) ToJson

func (me *PushNotificationAck) ToJson() string

type PushResponse

type PushResponse map[string]string

func LogError

func LogError(msg string) PushResponse

func NewErrorPushResponse

func NewErrorPushResponse(message string) PushResponse

func NewOkPushResponse

func NewOkPushResponse() PushResponse

func NewRemovePushResponse

func NewRemovePushResponse() PushResponse

func PushResponseFromJson

func PushResponseFromJson(data io.Reader) PushResponse

func (*PushResponse) ToJson

func (me *PushResponse) ToJson() string

Jump to

Keyboard shortcuts

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