pubnub

package module
Version: v4.10.0+incompatible Latest Latest
Warning

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

Go to latest
Published: Nov 2, 2020 License: MIT Imports: 26 Imported by: 43

README

PubNub Go SDK

GoDoc Build Status codecov.io Go Report Card

This is the official PubNub Go SDK repository.

PubNub takes care of the infrastructure and APIs needed for the realtime communication layer of your application. Work on your app's logic and let PubNub handle sending and receiving data across the world in less than 100ms.

Requirements

  • Go (1.9+)

Get keys

You will need the publish and subscribe keys to authenticate your app. Get your keys from the Admin Portal.

Configure PubNub

  1. Integrate PubNub into your project using the go command:

    go get github.com/pubnub/go
    

    If you encounter dependency issues, use the dep ensure command to resolve them.

  2. Create a new file and add the following code:

    func main() {
        config := pubnub.NewConfig()
        config.SubscribeKey = "mySubscribeKey"
        config.PublishKey = "myPublishKey"
        config.UUID = "myUniqueUUID"
    
        pn := pubnub.NewPubNub(config)
    }
    

Add event listeners

listener := pubnub.NewListener()
doneConnect := make(chan bool)
donePublish := make(chan bool)

msg := map[string]interface{}{
    "msg": "Hello world",
}
go func() {
    for {
        select {
        case status := <-listener.Status:
            switch status.Category {
            case pubnub.PNDisconnectedCategory:
                // This event happens when radio / connectivity is lost
            case pubnub.PNConnectedCategory:
                // Connect event. You can do stuff like publish, and know you'll get it.
                // Or just use the connected event to confirm you are subscribed for
                // UI / internal notifications, etc
                doneConnect <- true
            case pubnub.PNReconnectedCategory:
                // Happens as part of our regular operation. This event happens when
                // radio / connectivity is lost, then regained.
            }
        case message := <-listener.Message:
            // Handle new message stored in message.message
            if message.Channel != "" {
                // Message has been received on channel group stored in
                // message.Channel
            } else {
                // Message has been received on channel stored in
                // message.Subscription
            }
            if msg, ok := message.Message.(map[string]interface{}); ok {
                fmt.Println(msg["msg"])
            }
            /*
                log the following items with your favorite logger
                    - message.Message
                    - message.Subscription
                    - message.Timetoken
            */

            donePublish <- true
        case <-listener.Presence:
            // handle presence
        }
    }
}()

pn.AddListener(listener)

Publish and subscribe

In this code, publishing a message is triggered when the subscribe call is finished successfully. The Publish() method uses the msg variable that is used in the following code.

msg := map[string]interface{}{
        "msg": "Hello world!"
}

pn.Subscribe().
    Channels([]string{"hello_world"}).
    Execute()

<-doneConnect

response, status, err := pn.Publish().
    Channel("hello_world").Message(msg).Execute()

if err != nil {
     // Request processing failed.
     // Handle message publish error
}

Documentation

API reference for Go

Support

If you need help or have a general question, contact support@pubnub.com.

Documentation

Index

Constants

View Source
const (
	// PNObjectsMembershipEvent is the enum when the event of type `membership` occurs
	PNObjectsMembershipEvent PNObjectsEventType = "membership"
	// PNObjectsChannelEvent is the enum when the event of type `channel` occurs
	PNObjectsChannelEvent = "channel"
	// PNObjectsUUIDEvent is the enum when the event of type `uuid` occurs
	PNObjectsUUIDEvent = "uuid"
	// PNObjectsNoneEvent is used for error handling
	PNObjectsNoneEvent = "none"
)
View Source
const (
	// PNRead Read Perms
	PNRead PNGrantBitMask = 1
	// PNWrite Write Perms
	PNWrite = 2
	// PNManage Manage Perms
	PNManage = 4
	// PNDelete Delete Perms
	PNDelete = 8
	// PNCreate Create Perms
	PNCreate = 16
)
View Source
const (
	// Version :the version of the SDK
	Version = "4.10.0"
	// MaxSequence for publish messages
	MaxSequence = 65535
)

Default constants

View Source
const (
	// StrMissingPubKey shows Missing Publish Key message
	StrMissingPubKey = "Missing Publish Key"
	// StrMissingSubKey shows Missing Subscribe Key message
	StrMissingSubKey = "Missing Subscribe Key"
	// StrMissingChannel shows Channel message
	StrMissingChannel = "Missing Channel"
	// StrMissingChannelGroup shows Channel Group message
	StrMissingChannelGroup = "Missing Channel Group"
	// StrMissingMessage shows Missing Message message
	StrMissingMessage = "Missing Message"
	// StrMissingSecretKey shows Missing Secret Key message
	StrMissingSecretKey = "Missing Secret Key"
	// StrMissingUUID shows Missing UUID message
	StrMissingUUID = "Missing UUID"
	// StrMissingDeviceID shows Missing Device ID message
	StrMissingDeviceID = "Missing Device ID"
	// StrMissingPushType shows Missing Push Type message
	StrMissingPushType = "Missing Push Type"
	// StrMissingPushTopic shows Missing Push Topic message
	StrMissingPushTopic = "Missing Push Topic"
	// StrChannelsTimetoken shows Missing Channels Timetoken message
	StrChannelsTimetoken = "Missing Channels Timetoken"
	// StrChannelsTimetokenLength shows Length of Channels Timetoken message
	StrChannelsTimetokenLength = "Length of Channels Timetoken and Channels do not match"
	// StrInvalidTTL shows Invalid TTL message
	StrInvalidTTL = "Invalid TTL"
	// StrMissingPushTitle shows `Push title missing` message
	StrMissingPushTitle = "Push title missing"
	// StrMissingFileID shows `Missing File ID` message
	StrMissingFileID = "Missing File ID"
	// StrMissingFileName shows `Missing File Name` message
	StrMissingFileName = "Missing File Name"
)

Variables

This section is empty.

Functions

func EnumArrayToStringArray

func EnumArrayToStringArray(include interface{}) []string

EnumArrayToStringArray converts a string enum to an array

func NewHTTP1Client

func NewHTTP1Client(connectTimeout, responseReadTimeout, maxIdleConnsPerHost int) *http.Client

NewHTTP1Client creates a new HTTP 1 client with a new transport initialized with connect and read timeout

func NewHTTP2Client

func NewHTTP2Client(connectTimeout int, responseReadTimeout int) *http.Client

NewHTTP2Client creates a new HTTP 2 client with a new transport initialized with connect and read timeout

func ParseFileInfo

func ParseFileInfo(filesPayload map[string]interface{}) (PNFileDetails, PNPublishMessage)

ParseFileInfo is a function extract file info and add to the struct PNFileMessageAndDetails

func SetArrayTypeQueryParam

func SetArrayTypeQueryParam(q *url.Values, val []string, key string)

SetArrayTypeQueryParam appends to the query string the key val pair

func SetPushEnvironment

func SetPushEnvironment(q *url.Values, env PNPushEnvironment)

SetPushEnvironment appends the push environment to the query string

func SetPushTopic

func SetPushTopic(q *url.Values, topic string)

SetPushTopic appends the topic to the query string

func SetQueryParam

func SetQueryParam(q *url.Values, queryParam map[string]string)

SetQueryParam appends the query params map to the query string

func SetQueryParamAsCommaSepString

func SetQueryParamAsCommaSepString(q *url.Values, val []string, key string)

SetQueryParamAsCommaSepString appends to the query string the comma separated string.

Types

type AddChannelToChannelGroupResponse

type AddChannelToChannelGroupResponse struct {
}

AddChannelToChannelGroupResponse is the struct returned when the Execute function of AddChannelToChannelGroup is called.

type AddPushNotificationsOnChannelsResponse

type AddPushNotificationsOnChannelsResponse struct{}

AddPushNotificationsOnChannelsResponse is response structure for AddPushNotificationsOnChannelsBuilder

type AllChannelGroupResponse

type AllChannelGroupResponse struct {
	Channels     []string
	ChannelGroup string
}

AllChannelGroupResponse is the struct returned when the Execute function of List All Channel Groups is called.

type ChannelPermissions

type ChannelPermissions struct {
	Read   bool
	Write  bool
	Delete bool
}

ChannelPermissions contains all the acceptable perms for channels

type ChannelPermissionsWithToken

type ChannelPermissionsWithToken struct {
	Permissions  ChannelPermissions
	BitMaskPerms int64
	Token        string
	Timestamp    int64
	TTL          int
}

ChannelPermissionsWithToken is used for channels resource type permissions

type Config

type Config struct {
	sync.RWMutex
	PublishKey                    string             // PublishKey you can get it from admin panel (only required if publishing).
	SubscribeKey                  string             // SubscribeKey you can get it from admin panel.
	SecretKey                     string             // SecretKey (only required for modifying/revealing access permissions).
	AuthKey                       string             // AuthKey If Access Manager is utilized, client will use this AuthKey in all restricted requests.
	Origin                        string             // Custom Origin if needed
	UUID                          string             // UUID to be used as a device identifier, a default uuid is generated if not passed.
	CipherKey                     string             // If CipherKey is passed, all communications to/from PubNub will be encrypted.
	Secure                        bool               // True to use TLS
	ConnectTimeout                int                // net.Dialer.Timeout
	NonSubscribeRequestTimeout    int                // http.Client.Timeout for non-subscribe requests
	SubscribeRequestTimeout       int                // http.Client.Timeout for subscribe requests only
	FileUploadRequestTimeout      int                // http.Client.Timeout File Upload Request only
	HeartbeatInterval             int                // The frequency of the pings to the server to state that the client is active
	PresenceTimeout               int                // The time after which the server will send a timeout for the client
	MaximumReconnectionRetries    int                // The config sets how many times to retry to reconnect before giving up.
	MaximumLatencyDataAge         int                // Max time to store the latency data for telemetry
	FilterExpression              string             // Feature to subscribe with a custom filter expression.
	PNReconnectionPolicy          ReconnectionPolicy // Reconnection policy selection
	Log                           *log.Logger        // Logger instance
	SuppressLeaveEvents           bool               // When true the SDK doesn't send out the leave requests.
	DisablePNOtherProcessing      bool               // PNOther processing looks for pn_other in the JSON on the recevied message
	UseHTTP2                      bool               // HTTP2 Flag
	MessageQueueOverflowCount     int                // When the limit is exceeded by the number of messages received in a single subscribe request, a status event PNRequestMessageCountExceededCategory is fired.
	MaxIdleConnsPerHost           int                // Used to set the value of HTTP Transport's MaxIdleConnsPerHost.
	MaxWorkers                    int                // Number of max workers for Publish and Grant requests
	UsePAMV3                      bool               // Use PAM version 2, Objects requets would still use PAM v3
	StoreTokensOnGrant            bool               // Will store grant v3 tokens in token manager for further use.
	FileMessagePublishRetryLimit  int                // The number of tries made in case of Publish File Message failure.
	UseRandomInitializationVector bool               // When true the IV will be random for all requests and not just file upload. When false the IV will be hardcoded for all requests except File Upload
}

Config instance is storage for user-provided information which describe further PubNub client behaviour. Configuration instance contain additional set of properties which allow to perform precise PubNub client configuration.

func NewConfig

func NewConfig() *Config

NewConfig initiates the config with default values.

func NewDemoConfig

func NewDemoConfig() *Config

NewDemoConfig initiates the config with demo keys, for tests only.

func (*Config) SetPresenceTimeout

func (c *Config) SetPresenceTimeout(timeout int) *Config

SetPresenceTimeout sets the presence timeout and automatically calulates the preferred timeout value. timeout: How long the server will consider the client alive for presence.

func (*Config) SetPresenceTimeoutWithCustomInterval

func (c *Config) SetPresenceTimeoutWithCustomInterval(
	timeout, interval int) *Config

SetPresenceTimeoutWithCustomInterval sets the presence timeout and interval. timeout: How long the server will consider the client alive for presence. interval: How often the client will announce itself to server.

type Context

type Context interface {
	Deadline() (deadline time.Time, ok bool)
	Done() <-chan struct{}
	Err() error
	Value(key interface{}) interface{}
}

Context interface

type DeleteChannelGroupResponse

type DeleteChannelGroupResponse struct{}

DeleteChannelGroupResponse is response structure for Delete Channel Group function

type FetchResponse

type FetchResponse struct {
	Messages map[string][]FetchResponseItem
}

FetchResponse is the response to Fetch request. It contains a map of type FetchResponseItem

type FetchResponseItem

type FetchResponseItem struct {
	Message        interface{}                               `json:"message"`
	Meta           interface{}                               `json:"meta"`
	MessageActions map[string]PNHistoryMessageActionsTypeMap `json:"actions"`
	File           PNFileDetails                             `json:"file"`
	Timetoken      string                                    `json:"timetoken"`
	UUID           string                                    `json:"uuid"`
	MessageType    int                                       `json:"message_type"`
}

FetchResponseItem contains the message and the associated timetoken.

type GetStateResponse

type GetStateResponse struct {
	State map[string]interface{}
	UUID  string
}

GetStateResponse is the struct returned when the Execute function of GetState is called.

type GrantResources

type GrantResources struct {
	Channels map[string]int64 `json:"channels" cbor:"chan"`
	Groups   map[string]int64 `json:"groups" cbor:"grp"`
	Users    map[string]int64 `json:"users" cbor:"usr"`
	Spaces   map[string]int64 `json:"spaces" cbor:"spc"`
}

GrantResources is the struct used to decode the server response

type GrantResourcesWithPermissions

type GrantResourcesWithPermissions struct {
	Channels        map[string]ChannelPermissionsWithToken
	Groups          map[string]GroupPermissionsWithToken
	Users           map[string]UserSpacePermissionsWithToken
	Spaces          map[string]UserSpacePermissionsWithToken
	ChannelsPattern map[string]ChannelPermissionsWithToken
	GroupsPattern   map[string]GroupPermissionsWithToken
	UsersPattern    map[string]UserSpacePermissionsWithToken
	SpacesPattern   map[string]UserSpacePermissionsWithToken
}

GrantResourcesWithPermissions is used as a common struct to store all resource type permissions

func ParseGrantResources

func ParseGrantResources(res GrantResources, token string, timetoken int64, ttl int) *GrantResourcesWithPermissions

ParseGrantResources parses the token for permissions and adds them along the other values to the GrantResourcesWithPermissions struct

type GrantResponse

type GrantResponse struct {
	Level        string
	SubscribeKey string

	TTL int

	Channels      map[string]*PNPAMEntityData
	ChannelGroups map[string]*PNPAMEntityData
	UUIDs         map[string]*PNPAMEntityData

	ReadEnabled   bool
	WriteEnabled  bool
	ManageEnabled bool
	DeleteEnabled bool
	GetEnabled    bool
	UpdateEnabled bool
	JoinEnabled   bool
}

GrantResponse is the struct returned when the Execute function of Grant is called.

type GroupPermissions

type GroupPermissions struct {
	Read   bool
	Manage bool
}

GroupPermissions contains all the acceptable perms for groups

type GroupPermissionsWithToken

type GroupPermissionsWithToken struct {
	Permissions  GroupPermissions
	BitMaskPerms int64
	Token        string
	Timestamp    int64
	TTL          int
}

GroupPermissionsWithToken is used for groups resource type permissions

type HeartbeatManager

type HeartbeatManager struct {
	sync.RWMutex
	// contains filtered or unexported fields
}

HeartbeatManager is a struct that assists in running of the heartbeat.

func (*HeartbeatManager) Destroy

func (m *HeartbeatManager) Destroy()

Destroy stops the running heartbeat.

type HereNowChannelData

type HereNowChannelData struct {
	ChannelName string

	Occupancy int

	Occupants []HereNowOccupantsData
}

HereNowChannelData is the struct containing the occupancy details of the channels.

type HereNowOccupantsData

type HereNowOccupantsData struct {
	UUID string

	State map[string]interface{}
}

HereNowOccupantsData is the struct containing the state and UUID of the occupants in the channel.

type HereNowResponse

type HereNowResponse struct {
	TotalChannels  int
	TotalOccupancy int

	Channels []HereNowChannelData
}

HereNowResponse is the struct returned when the Execute function of HereNow is called.

type HistoryDeleteResponse

type HistoryDeleteResponse struct {
}

HistoryDeleteResponse is the struct returned when Delete Messages is called.

type HistoryResponse

type HistoryResponse struct {
	Messages       []HistoryResponseItem
	StartTimetoken int64
	EndTimetoken   int64
}

HistoryResponse is used to store the response from the History request.

type HistoryResponseItem

type HistoryResponseItem struct {
	Message   interface{}
	Meta      interface{}
	Timetoken int64
}

HistoryResponseItem is used to store the Message and the associated timetoken from the History request.

type JobQItem

type JobQItem struct {
	Req         *http.Request
	Client      *http.Client
	JobResponse chan *JobQResponse
}

JobQItem is the type to store the request, client and its resposne.

type JobQResponse

type JobQResponse struct {
	Resp  *http.Response
	Error error
}

JobQResponse is the type to store the resposne and error of the requests in the queue.

type LatencyEntry

type LatencyEntry struct {
	D int64
	L float64
}

LatencyEntry is the struct to store the timestamp and latency values.

type ListPushProvisionsRequestResponse

type ListPushProvisionsRequestResponse struct {
	Channels []string
}

ListPushProvisionsRequestResponse is the struct returned when the Execute function of ListPushProvisions is called.

type Listener

type Listener struct {
	Status              chan *PNStatus
	Message             chan *PNMessage
	Presence            chan *PNPresence
	Signal              chan *PNMessage
	UUIDEvent           chan *PNUUIDEvent
	ChannelEvent        chan *PNChannelEvent
	MembershipEvent     chan *PNMembershipEvent
	MessageActionsEvent chan *PNMessageActionsEvent
	File                chan *PNFilesEvent
}

Listener type has all the `types` of response events

func NewListener

func NewListener() *Listener

NewListener initates the listener to facilitate the event handling

type ListenerManager

type ListenerManager struct {
	sync.RWMutex
	// contains filtered or unexported fields
}

ListenerManager is used in the internal handling of listeners.

type MessageAction

type MessageAction struct {
	ActionType  string `json:"type"`
	ActionValue string `json:"value"`
}

MessageAction struct is used to create a Message Action

type MessageCountsResponse

type MessageCountsResponse struct {
	Channels map[string]int
}

MessageCountsResponse is the response to MessageCounts request. It contains a map of type MessageCountsResponseItem

type OperationType

type OperationType int

OperationType is used as an enum to catgorize the various operations in the APIs lifecycle

const (
	// PNSubscribeOperation is the enum used for the Subcribe operation.
	PNSubscribeOperation OperationType = 1 + iota
	// PNUnsubscribeOperation is the enum used for the Unsubcribe operation.
	PNUnsubscribeOperation
	// PNPublishOperation is the enum used for the Publish operation.
	PNPublishOperation
	// PNFireOperation is the enum used for the Fire operation.
	PNFireOperation
	// PNHistoryOperation is the enum used for the History operation.
	PNHistoryOperation
	// PNFetchMessagesOperation is the enum used for the Fetch operation.
	PNFetchMessagesOperation
	// PNWhereNowOperation is the enum used for the Where Now operation.
	PNWhereNowOperation
	// PNHereNowOperation is the enum used for the Here Now operation.
	PNHereNowOperation
	// PNHeartBeatOperation is the enum used for the Heartbeat operation.
	PNHeartBeatOperation
	// PNSetStateOperation is the enum used for the Set State operation.
	PNSetStateOperation
	// PNGetStateOperation is the enum used for the Get State operation.
	PNGetStateOperation
	// PNAddChannelsToChannelGroupOperation is the enum used for the Add Channels to Channel Group operation.
	PNAddChannelsToChannelGroupOperation
	// PNRemoveChannelFromChannelGroupOperation is the enum used for the Remove Channels from Channel Group operation.
	PNRemoveChannelFromChannelGroupOperation
	// PNRemoveGroupOperation is the enum used for the Remove Channel Group operation.
	PNRemoveGroupOperation
	// PNChannelsForGroupOperation is the enum used for the List Channels of Channel Group operation.
	PNChannelsForGroupOperation
	// PNPushNotificationsEnabledChannelsOperation is the enum used for the List Channels with Push Notifications enabled operation.
	PNPushNotificationsEnabledChannelsOperation
	// PNAddPushNotificationsOnChannelsOperation is the enum used for the Add Channels to Push Notifications operation.
	PNAddPushNotificationsOnChannelsOperation
	// PNRemovePushNotificationsFromChannelsOperation is the enum used for the Remove Channels from Push Notifications operation.
	PNRemovePushNotificationsFromChannelsOperation
	// PNRemoveAllPushNotificationsOperation is the enum used for the Remove All Channels from Push Notifications operation.
	PNRemoveAllPushNotificationsOperation
	// PNTimeOperation is the enum used for the Time operation.
	PNTimeOperation
	// PNAccessManagerGrant is the enum used for the Access Manager Grant operation.
	PNAccessManagerGrant
	// PNAccessManagerRevoke is the enum used for the Access Manager Revoke operation.
	PNAccessManagerRevoke
	// PNDeleteMessagesOperation is the enum used for the Delete Messages from History operation.
	PNDeleteMessagesOperation
	// PNMessageCountsOperation is the enum used for History with messages operation.
	PNMessageCountsOperation
	// PNSignalOperation is the enum used for Signal opertaion.
	PNSignalOperation
	// PNCreateUserOperation is the enum used to create users in the Object API.
	// ENUM ORDER needs to be maintained for Objects AIP
	PNCreateUserOperation
	// PNGetUsersOperation is the enum used to get users in the Object API.
	PNGetUsersOperation
	// PNGetUserOperation is the enum used to get user in the Object API.
	PNGetUserOperation
	// PNUpdateUserOperation is the enum used to update users in the Object API.
	PNUpdateUserOperation
	// PNDeleteUserOperation is the enum used to delete users in the Object API.
	PNDeleteUserOperation
	// PNGetSpaceOperation is the enum used to get space in the Object API.
	PNGetSpaceOperation
	// PNGetSpacesOperation is the enum used to get spaces in the Object API.
	PNGetSpacesOperation
	// PNCreateSpaceOperation is the enum used to create space in the Object API.
	PNCreateSpaceOperation
	// PNDeleteSpaceOperation is the enum used to delete space in the Object API.
	PNDeleteSpaceOperation
	// PNUpdateSpaceOperation is the enum used to update space in the Object API.
	PNUpdateSpaceOperation
	// PNGetMembershipsOperation is the enum used to get memberships in the Object API.
	PNGetMembershipsOperation
	// PNGetChannelMembersOperation is the enum used to get members in the Object API.
	PNGetChannelMembersOperation
	// PNManageMembershipsOperation is the enum used to manage memberships in the Object API.
	PNManageMembershipsOperation
	// PNManageMembersOperation is the enum used to manage members in the Object API.
	// ENUM ORDER needs to be maintained for Objects API.
	PNManageMembersOperation
	// PNSetChannelMembersOperation is the enum used to Set Members in the Object API.
	PNSetChannelMembersOperation
	// PNSetMembershipsOperation is the enum used to Set Memberships in the Object API.
	PNSetMembershipsOperation
	// PNRemoveChannelMetadataOperation is the enum used to Remove Channel Metadata in the Object API.
	PNRemoveChannelMetadataOperation
	// PNRemoveUUIDMetadataOperation is the enum used to Remove UUID Metadata in the Object API.
	PNRemoveUUIDMetadataOperation
	// PNGetAllChannelMetadataOperation is the enum used to Get All Channel Metadata in the Object API.
	PNGetAllChannelMetadataOperation
	// PNGetAllUUIDMetadataOperation is the enum used to Get All UUID Metadata in the Object API.
	PNGetAllUUIDMetadataOperation
	// PNGetUUIDMetadataOperation is the enum used to Get UUID Metadata in the Object API.
	PNGetUUIDMetadataOperation
	// PNRemoveMembershipsOperation is the enum used to Remove Memberships in the Object API.
	PNRemoveMembershipsOperation
	// PNRemoveChannelMembersOperation is the enum used to Remove Members in the Object API.
	PNRemoveChannelMembersOperation
	// PNSetUUIDMetadataOperation is the enum used to Set UUID Metadata in the Object API.
	PNSetUUIDMetadataOperation
	// PNSetChannelMetadataOperation is the enum used to Set Channel Metadata in the Object API.
	PNSetChannelMetadataOperation
	// PNGetChannelMetadataOperation is the enum used to Get Channel Metadata in the Object API.
	PNGetChannelMetadataOperation
	// PNAccessManagerGrantToken is the enum used for Grant v3 requests.
	PNAccessManagerGrantToken
	// PNGetMessageActionsOperation is the enum used for Message Actions Get requests.
	PNGetMessageActionsOperation
	// PNHistoryWithActionsOperation is the enum used for History with Actions requests.
	PNHistoryWithActionsOperation
	// PNAddMessageActionsOperation is the enum used for Message Actions Add requests.
	PNAddMessageActionsOperation
	// PNRemoveMessageActionsOperation is the enum used for Message Actions Remove requests.
	PNRemoveMessageActionsOperation
	// PNDeleteFileOperation is the enum used for DeleteFile requests.
	PNDeleteFileOperation
	// PNDownloadFileOperation is the enum used for DownloadFile requests.
	PNDownloadFileOperation
	// PNGetFileURLOperation is the enum used for GetFileURL requests.
	PNGetFileURLOperation
	// PNListFilesOperation is the enum used for ListFiles requests.
	PNListFilesOperation
	// PNSendFileOperation is the enum used for SendFile requests.
	PNSendFileOperation
	// PNSendFileToS3Operation is the enum used for v requests.
	PNSendFileToS3Operation
	// PNPublishFileMessageOperation is the enum used for PublishFileMessage requests.
	PNPublishFileMessageOperation
)

func (OperationType) String

func (t OperationType) String() string

type Operations

type Operations struct {
	// contains filtered or unexported fields
}

Operations is the struct to store the latency values of different operations.

type PNAPNS2Data

type PNAPNS2Data struct {
	CollapseID string         `json:"collapseId"`
	Expiration string         `json:"expiration"`
	Targets    []PNPushTarget `json:"targets"`
	Version    string         `json:"version"`
}

PNAPNS2Data is the struct used for the APNS2 paylod

type PNAPNSData

type PNAPNSData struct {
	APS    PNAPSData `json:"aps"`
	Custom map[string]interface{}
}

PNAPNSData is the struct used for the APNS paylod

type PNAPSData

type PNAPSData struct {
	Alert    interface{} `json:"alert"`
	Badge    int         `json:"badge"`
	Sound    string      `json:"sound"`
	Title    string      `json:"title"`
	Subtitle string      `json:"subtitle"`
	Body     string      `json:"body"`
	Custom   map[string]interface{}
}

PNAPSData is the helper struct used for the APNS paylod

type PNAccessManagerKeyData

type PNAccessManagerKeyData struct {
	ReadEnabled   bool
	WriteEnabled  bool
	ManageEnabled bool
	DeleteEnabled bool
	GetEnabled    bool
	UpdateEnabled bool
	JoinEnabled   bool
	TTL           int
}

PNAccessManagerKeyData is the struct containing the access details of the channel groups.

type PNAddMessageActionsResponse

type PNAddMessageActionsResponse struct {
	Data PNMessageActionsResponse `json:"data"`
	// contains filtered or unexported fields
}

PNAddMessageActionsResponse is the Add Message Actions API Response

type PNChannel

type PNChannel struct {
	ID          string                 `json:"id"`
	Name        string                 `json:"name"`
	Description string                 `json:"description"`
	Updated     string                 `json:"updated"`
	ETag        string                 `json:"eTag"`
	Custom      map[string]interface{} `json:"custom"`
}

PNChannel is the Objects API space struct

type PNChannelEvent

type PNChannelEvent struct {
	Event             PNObjectsEvent
	ChannelID         string
	Description       string
	Timestamp         string
	Name              string
	Updated           string
	ETag              string
	Custom            map[string]interface{}
	SubscribedChannel string
	ActualChannel     string
	Channel           string
	Subscription      string
}

PNChannelEvent is the Response for a Space Event

type PNChannelMembers

type PNChannelMembers struct {
	ID      string                 `json:"id"`
	UUID    PNUUID                 `json:"uuid"`
	Created string                 `json:"created"`
	Updated string                 `json:"updated"`
	ETag    string                 `json:"eTag"`
	Custom  map[string]interface{} `json:"custom"`
}

PNChannelMembers is the Objects API Members struct

type PNChannelMembersInclude

type PNChannelMembersInclude int

PNChannelMembersInclude is used as an enum to catgorize the available Members include types

const (
	// PNChannelMembersIncludeCustom is the enum equivalent to the value `custom` available Members include types
	PNChannelMembersIncludeCustom PNChannelMembersInclude = 1 + iota
	// PNChannelMembersIncludeUUID is the enum equivalent to the value `uuid` available Members include types
	PNChannelMembersIncludeUUID
	// PNChannelMembersIncludeUUIDCustom is the enum equivalent to the value `uuid.custom` available Members include types
	PNChannelMembersIncludeUUIDCustom
)

func (PNChannelMembersInclude) String

func (s PNChannelMembersInclude) String() string

type PNChannelMembersRemove

type PNChannelMembersRemove struct {
	UUID PNChannelMembersUUID `json:"uuid"`
}

PNChannelMembersRemove is the Objects API Members struct used to remove members

type PNChannelMembersRemoveChangeset

type PNChannelMembersRemoveChangeset struct {
	Remove []PNChannelMembersRemove `json:"delete"`
}

PNChannelMembersRemoveChangeset is the Objects API input to add, remove or update membership

type PNChannelMembersSet

type PNChannelMembersSet struct {
	UUID   PNChannelMembersUUID   `json:"uuid"`
	Custom map[string]interface{} `json:"custom"`
}

PNChannelMembersSet is the Objects API Members input struct used to add members

type PNChannelMembersSetChangeset

type PNChannelMembersSetChangeset struct {
	Set []PNChannelMembersSet `json:"set"`
}

PNChannelMembersSetChangeset is the Objects API input to add, remove or update membership

type PNChannelMembersUUID

type PNChannelMembersUUID struct {
	ID string `json:"id"`
}

PNChannelMembersUUID is the Objects API Members input struct used to add members

type PNChannelMetadataInclude

type PNChannelMetadataInclude int

PNChannelMetadataInclude is used as an enum to catgorize the available Channel include types

const (
	// PNChannelMetadataIncludeCustom is the enum equivalent to the value `custom` available Channel include types
	PNChannelMetadataIncludeCustom PNChannelMetadataInclude = 1 + iota
)

func (PNChannelMetadataInclude) String

func (s PNChannelMetadataInclude) String() string

type PNDeleteFileResponse

type PNDeleteFileResponse struct {
	// contains filtered or unexported fields
}

PNDeleteFileResponse is the File Upload API Response for Delete file operation

type PNDownloadFileResponse

type PNDownloadFileResponse struct {
	File io.Reader `json:"data"`
	// contains filtered or unexported fields
}

PNDownloadFileResponse is the File Upload API Response for Get Spaces

type PNFCMData

type PNFCMData struct {
	Data   PNFCMDataFields `json:"data"`
	Custom map[string]interface{}
}

PNFCMData is the struct used for the FCM paylod

type PNFCMDataFields

type PNFCMDataFields struct {
	Summary interface{} `json:"summary"`
	Custom  map[string]interface{}
}

PNFCMDataFields is the helper struct used for the FCM paylod

type PNFileData

type PNFileData struct {
	ID string `json:"id"`
}

PNFileData is used in the responses to show File ID

type PNFileDetails

type PNFileDetails struct {
	Name string `json:"name"`
	ID   string `json:"id"`
	URL  string
}

PNFileDetails is used in the responses to show File Info

type PNFileInfo

type PNFileInfo struct {
	Name    string `json:"name"`
	ID      string `json:"id"`
	Size    int    `json:"size"`
	Created string `json:"created"`
}

PNFileInfo is the File Upload API struct returned on for each file.

type PNFileInfoForPublish

type PNFileInfoForPublish struct {
	Name string `json:"name"`
	ID   string `json:"id"`
}

PNFileInfoForPublish is the part of the message struct used in Publish File

type PNFileMessageAndDetails

type PNFileMessageAndDetails struct {
	PNMessage PNPublishMessage `json:"message"`
	PNFile    PNFileDetails    `json:"file"`
}

PNFileMessageAndDetails is used to store the file message and file info

type PNFileUploadRequest

type PNFileUploadRequest struct {
	URL        string        `json:"url"`
	Method     string        `json:"method"`
	FormFields []PNFormField `json:"form_fields"`
}

PNFileUploadRequest is used to store the info related to file upload to S3

type PNFilesEvent

type PNFilesEvent struct {
	File              PNFileMessageAndDetails
	UserMetadata      interface{}
	SubscribedChannel string
	ActualChannel     string
	Channel           string
	Subscription      string
	Publisher         string
	Timetoken         int64
}

PNFilesEvent is the Response for a Files Event

type PNFormField

type PNFormField struct {
	Key   string `json:"key"`
	Value string `json:"value"`
}

PNFormField is part of the struct used in file upload to S3

type PNGetAllChannelMetadataResponse

type PNGetAllChannelMetadataResponse struct {
	Data       []PNChannel `json:"data"`
	TotalCount int         `json:"totalCount"`
	Next       string      `json:"next"`
	Prev       string      `json:"prev"`
	// contains filtered or unexported fields
}

PNGetAllChannelMetadataResponse is the Objects API Response for Get Spaces

type PNGetAllUUIDMetadataResponse

type PNGetAllUUIDMetadataResponse struct {
	Data       []PNUUID `json:"data"`
	TotalCount int      `json:"totalCount"`
	Next       string   `json:"next"`
	Prev       string   `json:"prev"`
	// contains filtered or unexported fields
}

PNGetAllUUIDMetadataResponse is the Objects API Response for Get Users

type PNGetChannelMembersResponse

type PNGetChannelMembersResponse struct {
	Data       []PNChannelMembers `json:"data"`
	TotalCount int                `json:"totalCount"`
	Next       string             `json:"next"`
	Prev       string             `json:"prev"`
	// contains filtered or unexported fields
}

PNGetChannelMembersResponse is the Objects API Response for Get Members

type PNGetChannelMetadataResponse

type PNGetChannelMetadataResponse struct {
	Data PNChannel `json:"data"`
	// contains filtered or unexported fields
}

PNGetChannelMetadataResponse is the Objects API Response for Get Space

type PNGetFileURLResponse

type PNGetFileURLResponse struct {
	URL string `json:"location"`
}

PNGetFileURLResponse is the File Upload API Response for Get Spaces

type PNGetMembershipsResponse

type PNGetMembershipsResponse struct {
	Data       []PNMemberships `json:"data"`
	TotalCount int             `json:"totalCount"`
	Next       string          `json:"next"`
	Prev       string          `json:"prev"`
	// contains filtered or unexported fields
}

PNGetMembershipsResponse is the Objects API Response for Get Memberships

type PNGetMessageActionsMore

type PNGetMessageActionsMore struct {
	URL   string `json:"url"`
	Start string `json:"start"`
	End   string `json:"end"`
	Limit int    `json:"limit"`
}

PNGetMessageActionsMore is the struct used when the PNGetMessageActionsResponse has more link

type PNGetMessageActionsResponse

type PNGetMessageActionsResponse struct {
	Data []PNMessageActionsResponse `json:"data"`
	More PNGetMessageActionsMore    `json:"more"`
	// contains filtered or unexported fields
}

PNGetMessageActionsResponse is the GetMessageActions API Response

type PNGetUUIDMetadataResponse

type PNGetUUIDMetadataResponse struct {
	Data PNUUID `json:"data"`
	// contains filtered or unexported fields
}

PNGetUUIDMetadataResponse is the Objects API Response for Get User

type PNGrantBitMask

type PNGrantBitMask int64

PNGrantBitMask is the type for perms BitMask

type PNGrantTokenData

type PNGrantTokenData struct {
	Message string `json:"message"`
	Token   string `json:"token"`
}

PNGrantTokenData is the struct used to decode the server response

type PNGrantTokenDecoded

type PNGrantTokenDecoded struct {
	Resources GrantResources         `cbor:"res"`
	Patterns  GrantResources         `cbor:"pat"`
	Meta      map[string]interface{} `cbor:"meta"`
	Signature []byte                 `cbor:"sig"`
	Version   int                    `cbor:"v"`
	Timestamp int64                  `cbor:"t"`
	TTL       int                    `cbor:"ttl"`
}

PNGrantTokenDecoded is the struct used to decode the server response

func GetPermissions

func GetPermissions(token string) (PNGrantTokenDecoded, error)

GetPermissions decodes the CBORToken

type PNGrantTokenResponse

type PNGrantTokenResponse struct {
	Data PNGrantTokenData `json:"data"`
	// contains filtered or unexported fields
}

PNGrantTokenResponse is the struct returned when the Execute function of Grant Token is called.

type PNGrantType

type PNGrantType int

PNGrantType grant types

const (
	// PNReadEnabled Read Enabled. Applies to Subscribe, History, Presence, Objects
	PNReadEnabled PNGrantType = 1 + iota
	// PNWriteEnabled Write Enabled. Applies to Publish, Objects
	PNWriteEnabled
	// PNManageEnabled Manage Enabled. Applies to Channel-Groups, Objects
	PNManageEnabled
	// PNDeleteEnabled Delete Enabled. Applies to History, Objects
	PNDeleteEnabled
	// PNCreateEnabled Create Enabled. Applies to Objects
	PNCreateEnabled
	// PNGetEnabled Get Enabled. Applies to Objects
	PNGetEnabled
	// PNUpdateEnabled Update Enabled. Applies to Objects
	PNUpdateEnabled
	// PNJoinEnabled Join Enabled. Applies to Objects
	PNJoinEnabled
)

type PNHistoryMessageActionTypeVal

type PNHistoryMessageActionTypeVal struct {
	UUID            string `json:"uuid"`
	ActionTimetoken string `json:"actionTimetoken"`
}

PNHistoryMessageActionTypeVal is the struct used in the Fetch request that includes Message Actions

type PNHistoryMessageActionsTypeMap

type PNHistoryMessageActionsTypeMap struct {
	ActionsTypeValues map[string][]PNHistoryMessageActionTypeVal `json:"-"`
}

PNHistoryMessageActionsTypeMap is the struct used in the Fetch request that includes Message Actions

type PNListFilesResponse

type PNListFilesResponse struct {
	Data  []PNFileInfo `json:"data"`
	Count int          `json:"count"`
	Next  string       `json:"next"`
	// contains filtered or unexported fields
}

PNListFilesResponse is the File Upload API Response for Get Spaces

type PNMPNSData

type PNMPNSData struct {
	Title       string `json:"title"`
	Type        string `json:"type"`
	Count       int    `json:"count"`
	BackTitle   string `json:"back_title"`
	BackContent string `json:"back_content"`
	Custom      map[string]interface{}
}

PNMPNSData is the struct used for the MPNS paylod

type PNManageChannelMembersBody

type PNManageChannelMembersBody struct {
	Set    []PNChannelMembersSet    `json:"set"`
	Remove []PNChannelMembersRemove `json:"delete"`
}

PNManageChannelMembersBody is the Objects API input to add, remove or update members

type PNManageMembersResponse

type PNManageMembersResponse struct {
	Data       []PNChannelMembers `json:"data"`
	TotalCount int                `json:"totalCount"`
	Next       string             `json:"next"`
	Prev       string             `json:"prev"`
	// contains filtered or unexported fields
}

PNManageMembersResponse is the Objects API Response for ManageMembers

type PNManageMembershipsBody

type PNManageMembershipsBody struct {
	Set    []PNMembershipsSet    `json:"set"`
	Remove []PNMembershipsRemove `json:"delete"`
}

PNManageMembershipsBody is the Objects API input to add, remove or update membership

type PNManageMembershipsResponse

type PNManageMembershipsResponse struct {
	Data       []PNMemberships `json:"data"`
	TotalCount int             `json:"totalCount"`
	Next       string          `json:"next"`
	Prev       string          `json:"prev"`
	// contains filtered or unexported fields
}

PNManageMembershipsResponse is the Objects API Response for ManageMemberships

type PNMembersAddChangeSet

type PNMembersAddChangeSet struct {
	Set []PNMembershipsSet `json:"set"`
}

PNMembersAddChangeSet is the Objects API input to add, remove or update members

type PNMembershipEvent

type PNMembershipEvent struct {
	Event             PNObjectsEvent
	UUID              string
	ChannelID         string
	Description       string
	Timestamp         string
	Custom            map[string]interface{}
	SubscribedChannel string
	ActualChannel     string
	Channel           string
	Subscription      string
}

PNMembershipEvent is the Response for a Membership Event

type PNMemberships

type PNMemberships struct {
	ID      string                 `json:"id"`
	Channel PNChannel              `json:"channel"`
	Created string                 `json:"created"`
	Updated string                 `json:"updated"`
	ETag    string                 `json:"eTag"`
	Custom  map[string]interface{} `json:"custom"`
}

PNMemberships is the Objects API Memberships struct

type PNMembershipsChannel

type PNMembershipsChannel struct {
	ID string `json:"id"`
}

PNMembershipsChannel is the Objects API Memberships input struct used to add members

type PNMembershipsInclude

type PNMembershipsInclude int

PNMembershipsInclude is used as an enum to catgorize the available Memberships include types

const (
	// PNMembershipsIncludeCustom is the enum equivalent to the value `custom` available Memberships include types
	PNMembershipsIncludeCustom PNMembershipsInclude = 1 + iota
	// PNMembershipsIncludeChannel is the enum equivalent to the value `channel` available Memberships include types
	PNMembershipsIncludeChannel
	// PNMembershipsIncludeChannelCustom is the enum equivalent to the value `channel.custom` available Memberships include types
	PNMembershipsIncludeChannelCustom
)

func (PNMembershipsInclude) String

func (s PNMembershipsInclude) String() string

type PNMembershipsRemove

type PNMembershipsRemove struct {
	Channel PNMembershipsChannel `json:"channel"`
}

PNMembershipsRemove is the Objects API Memberships struct used to remove members

type PNMembershipsRemoveChangeSet

type PNMembershipsRemoveChangeSet struct {
	Remove []PNMembershipsRemove `json:"delete"`
}

PNMembershipsRemoveChangeSet is the Objects API input to add, remove or update members

type PNMembershipsSet

type PNMembershipsSet struct {
	Channel PNMembershipsChannel   `json:"channel"`
	Custom  map[string]interface{} `json:"custom"`
}

PNMembershipsSet is the Objects API Memberships input struct used to add members

type PNMessage

type PNMessage struct {
	Message           interface{}
	UserMetadata      interface{}
	SubscribedChannel string
	ActualChannel     string
	Channel           string
	Subscription      string
	Publisher         string
	Timetoken         int64
}

PNMessage is the Message Response for Subscribe

type PNMessageActionsEvent

type PNMessageActionsEvent struct {
	Event             PNMessageActionsEventType
	Data              PNMessageActionsResponse
	SubscribedChannel string
	ActualChannel     string
	Channel           string
	Subscription      string
}

PNMessageActionsEvent is the Response for a Message Actions Event

type PNMessageActionsEventType

type PNMessageActionsEventType string

PNMessageActionsEventType is used as an enum to catgorize the available Message Actions Event types

const (
	// PNMessageActionsAdded is the enum when the event of type `added` occurs
	PNMessageActionsAdded PNMessageActionsEventType = "added"
	// PNMessageActionsRemoved is the enum when the event of type `removed` occurs
	PNMessageActionsRemoved = "removed"
)

type PNMessageActionsResponse

type PNMessageActionsResponse struct {
	ActionType       string `json:"type"`
	ActionValue      string `json:"value"`
	ActionTimetoken  string `json:"actionTimetoken"`
	MessageTimetoken string `json:"messageTimetoken"`
	UUID             string `json:"uuid"`
}

PNMessageActionsResponse Message Actions response.

type PNMessageType

type PNMessageType int

PNMessageType is used as an enum to catgorize the Subscribe response.

const (
	// PNMessageTypeSignal is to identify Signal the Subscribe response
	PNMessageTypeSignal PNMessageType = 1 + iota
	// PNMessageTypeObjects is to identify Objects the Subscribe response
	PNMessageTypeObjects
	// PNMessageTypeMessageActions is to identify Actions the Subscribe response
	PNMessageTypeMessageActions
	// PNMessageTypeFile is to identify Files the Subscribe response
	PNMessageTypeFile
)

type PNObjectsEvent

type PNObjectsEvent string

PNObjectsEvent is used as an enum to catgorize the available Object Events

const (
	// PNObjectsEventRemove is the enum when the event `delete` occurs
	PNObjectsEventRemove PNObjectsEvent = "delete"
	// PNObjectsEventSet is the enum when the event `set` occurs
	PNObjectsEventSet = "set"
)

type PNObjectsEventType

type PNObjectsEventType string

PNObjectsEventType is used as an enum to catgorize the available Object Event types

type PNObjectsResponse

type PNObjectsResponse struct {
	Event       PNObjectsEvent         `json:"event"` // enum value
	EventType   PNObjectsEventType     `json:"type"`  // enum value
	Name        string                 `json:"name"`
	ID          string                 `json:"id"`          // the uuid if user related
	Channel     string                 `json:"channel"`     // the channel if space related
	Description string                 `json:"description"` // the description of what happened
	Timestamp   string                 `json:"timestamp"`   // the timetoken of the event
	ExternalID  string                 `json:"externalId"`
	ProfileURL  string                 `json:"profileUrl"`
	Email       string                 `json:"email"`
	Updated     string                 `json:"updated"`
	ETag        string                 `json:"eTag"`
	Custom      map[string]interface{} `json:"custom"`
	Data        map[string]interface{} `json:"data"`
}

PNObjectsResponse is the Objects API collective Response struct of all methods.

type PNPAMEntityData

type PNPAMEntityData struct {
	Name          string
	AuthKeys      map[string]*PNAccessManagerKeyData
	ReadEnabled   bool
	WriteEnabled  bool
	ManageEnabled bool
	DeleteEnabled bool
	GetEnabled    bool
	UpdateEnabled bool
	JoinEnabled   bool
	TTL           int
}

PNPAMEntityData is the struct containing the access details of the channels.

type PNPresence

type PNPresence struct {
	Event             string
	UUID              string
	SubscribedChannel string
	ActualChannel     string
	Channel           string
	Subscription      string
	Occupancy         int
	Timetoken         int64
	Timestamp         int64
	UserMetadata      map[string]interface{}
	State             interface{}
	Join              []string
	Leave             []string
	Timeout           []string
	HereNowRefresh    bool
}

PNPresence is the Message Response for Presence

type PNPublishFileMessage

type PNPublishFileMessage struct {
	PNMessage *PNPublishMessage     `json:"message"`
	PNFile    *PNFileInfoForPublish `json:"file"`
}

PNPublishFileMessage is the message struct used in Publish File

type PNPublishMessage

type PNPublishMessage struct {
	Text string `json:"text"`
}

PNPublishMessage is the part of the message struct used in Publish File

type PNPushEnvironment

type PNPushEnvironment string

PNPushEnvironment is used as an enum to catgorize the available Message Actions Event types

const (
	//PNPushEnvironmentDevelopment for development
	PNPushEnvironmentDevelopment PNPushEnvironment = "development"
	//PNPushEnvironmentProduction for production
	PNPushEnvironmentProduction = "production"
)

type PNPushTarget

type PNPushTarget struct {
	Topic          string            `json:"topic"`
	ExcludeDevices []string          `json:"exclude_devices"`
	Environment    PNPushEnvironment `json:"environment"`
}

PNPushTarget is the helper struct used for the APNS2 paylod

type PNPushType

type PNPushType int

PNPushType is used as an enum to catgorize the available Push Types

const (
	// PNPushTypeNone is used as an enum to for selecting `none` as the PNPushType
	PNPushTypeNone PNPushType = 1 + iota
	// PNPushTypeGCM is used as an enum to for selecting `GCM` as the PNPushType
	PNPushTypeGCM
	// PNPushTypeAPNS is used as an enum to for selecting `APNS` as the PNPushType
	PNPushTypeAPNS
	// PNPushTypeMPNS is used as an enum to for selecting `MPNS` as the PNPushType
	PNPushTypeMPNS
	// PNPushTypeAPNS2 is used as an enum to for selecting `APNS2` as the PNPushType
	PNPushTypeAPNS2
)

func (PNPushType) String

func (p PNPushType) String() string

type PNRemoveChannelMembersResponse

type PNRemoveChannelMembersResponse struct {
	Data       []PNChannelMembers `json:"data"`
	TotalCount int                `json:"totalCount"`
	Next       string             `json:"next"`
	Prev       string             `json:"prev"`
	// contains filtered or unexported fields
}

PNRemoveChannelMembersResponse is the Objects API Response for RemoveChannelMembers

type PNRemoveChannelMetadataResponse

type PNRemoveChannelMetadataResponse struct {
	Data interface{} `json:"data"`
	// contains filtered or unexported fields
}

PNRemoveChannelMetadataResponse is the Objects API Response for delete space

type PNRemoveMembershipsResponse

type PNRemoveMembershipsResponse struct {
	Data       []PNMemberships `json:"data"`
	TotalCount int             `json:"totalCount"`
	Next       string          `json:"next"`
	Prev       string          `json:"prev"`
	// contains filtered or unexported fields
}

PNRemoveMembershipsResponse is the Objects API Response for RemoveMemberships

type PNRemoveMessageActionsResponse

type PNRemoveMessageActionsResponse struct {
	Data interface{} `json:"data"`
	// contains filtered or unexported fields
}

PNRemoveMessageActionsResponse is the Objects API Response for create space

type PNRemoveUUIDMetadataResponse

type PNRemoveUUIDMetadataResponse struct {
	Data interface{} `json:"data"`
	// contains filtered or unexported fields
}

PNRemoveUUIDMetadataResponse is the Objects API Response for delete user

type PNResourceType

type PNResourceType int

PNResourceType grant types

const (
	// PNChannels for channels
	PNChannels PNResourceType = 1 + iota
	// PNGroups for groups
	PNGroups
	// PNUsers for users
	PNUsers
	// PNSpaces for spaces
	PNSpaces
)

type PNSendFileBody

type PNSendFileBody struct {
	Name string `json:"name"`
}

PNSendFileBody is used to create the body of the request

type PNSendFileResponse

type PNSendFileResponse struct {
	Timestamp int64

	Data PNFileData `json:"data"`
	// contains filtered or unexported fields
}

PNSendFileResponse is the type used to store the response info of Send File.

type PNSendFileResponseForS3

type PNSendFileResponseForS3 struct {
	Data              PNFileData          `json:"data"`
	FileUploadRequest PNFileUploadRequest `json:"file_upload_request"`
	// contains filtered or unexported fields
}

PNSendFileResponseForS3 is the File Upload API Response for SendFile.

type PNSendFileToS3Response

type PNSendFileToS3Response struct {
}

PNSendFileToS3Response is the File Upload API Response for Get Spaces

type PNSetChannelMembersResponse

type PNSetChannelMembersResponse struct {
	Data       []PNChannelMembers `json:"data"`
	TotalCount int                `json:"totalCount"`
	Next       string             `json:"next"`
	Prev       string             `json:"prev"`
	// contains filtered or unexported fields
}

PNSetChannelMembersResponse is the Objects API Response for SetChannelMembers

type PNSetChannelMetadataResponse

type PNSetChannelMetadataResponse struct {
	Data PNChannel `json:"data"`
	// contains filtered or unexported fields
}

PNSetChannelMetadataResponse is the Objects API Response for Update Space

type PNSetMembershipsResponse

type PNSetMembershipsResponse struct {
	Data       []PNMemberships `json:"data"`
	TotalCount int             `json:"totalCount"`
	Next       string          `json:"next"`
	Prev       string          `json:"prev"`
	// contains filtered or unexported fields
}

PNSetMembershipsResponse is the Objects API Response for SetMemberships

type PNSetUUIDMetadataResponse

type PNSetUUIDMetadataResponse struct {
	Data PNUUID `json:"data"`
	// contains filtered or unexported fields
}

PNSetUUIDMetadataResponse is the Objects API Response for Update user

type PNStatus

type PNStatus struct {
	Category              StatusCategory
	Operation             OperationType
	ErrorData             error
	Error                 bool
	TLSEnabled            bool
	StatusCode            int
	UUID                  string
	AuthKey               string
	Origin                string
	ClientRequest         interface{} // Should be same for non-google environment
	AffectedChannels      []string
	AffectedChannelGroups []string
}

PNStatus is the status struct

type PNUUID

type PNUUID struct {
	ID         string                 `json:"id"`
	Name       string                 `json:"name"`
	ExternalID string                 `json:"externalId"`
	ProfileURL string                 `json:"profileUrl"`
	Email      string                 `json:"email"`
	Updated    string                 `json:"updated"`
	ETag       string                 `json:"eTag"`
	Custom     map[string]interface{} `json:"custom"`
}

PNUUID is the Objects API user struct

type PNUUIDEvent

type PNUUIDEvent struct {
	Event             PNObjectsEvent
	UUID              string
	Description       string
	Timestamp         string
	Name              string
	ExternalID        string
	ProfileURL        string
	Email             string
	Updated           string
	ETag              string
	Custom            map[string]interface{}
	SubscribedChannel string
	ActualChannel     string
	Channel           string
	Subscription      string
}

PNUUIDEvent is the Response for an User Event

type PNUUIDMetadataInclude

type PNUUIDMetadataInclude int

PNUUIDMetadataInclude is used as an enum to catgorize the available UUID include types

const (
	// PNUUIDMetadataIncludeCustom is the enum equivalent to the value `custom` available UUID include types
	PNUUIDMetadataIncludeCustom PNUUIDMetadataInclude = 1 + iota
)

func (PNUUIDMetadataInclude) String

func (s PNUUIDMetadataInclude) String() string

type PermissionsBody

type PermissionsBody struct {
	Resources GrantResources         `json:"resources"`
	Patterns  GrantResources         `json:"patterns"`
	Meta      map[string]interface{} `json:"meta"`
}

PermissionsBody is the struct used to decode the server response

type PubNub

type PubNub struct {
	sync.RWMutex

	Config *Config
	// contains filtered or unexported fields
}

PubNub No server connection will be established when you create a new PubNub object. To establish a new connection use Subscribe() function of PubNub type.

func NewPubNub

func NewPubNub(pnconf *Config) *PubNub

NewPubNub instantiates a PubNub instance with default values.

func NewPubNubDemo

func NewPubNubDemo() *PubNub

NewPubNubDemo returns an instance with demo keys

func (*PubNub) AddChannelToChannelGroup

func (pn *PubNub) AddChannelToChannelGroup() *addChannelToChannelGroupBuilder

AddChannelToChannelGroup This function adds a channel to a channel group.

func (*PubNub) AddChannelToChannelGroupWithContext

func (pn *PubNub) AddChannelToChannelGroupWithContext(ctx Context) *addChannelToChannelGroupBuilder

AddChannelToChannelGroupWithContext This function adds a channel to a channel group.

func (*PubNub) AddListener

func (pn *PubNub) AddListener(listener *Listener)

AddListener lets you add a new listener.

func (*PubNub) AddMessageAction

func (pn *PubNub) AddMessageAction() *addMessageActionsBuilder

AddMessageAction Add an action on a published message. Returns the added action in the response.

func (*PubNub) AddMessageActionWithContext

func (pn *PubNub) AddMessageActionWithContext(ctx Context) *addMessageActionsBuilder

AddMessageActionWithContext Add an action on a published message. Returns the added action in the response.

func (*PubNub) AddPushNotificationsOnChannels

func (pn *PubNub) AddPushNotificationsOnChannels() *addPushNotificationsOnChannelsBuilder

AddPushNotificationsOnChannels Enable push notifications on provided set of channels.

func (*PubNub) AddPushNotificationsOnChannelsWithContext

func (pn *PubNub) AddPushNotificationsOnChannelsWithContext(ctx Context) *addPushNotificationsOnChannelsBuilder

AddPushNotificationsOnChannelsWithContext Enable push notifications on provided set of channels.

func (*PubNub) CreatePushPayload

func (pn *PubNub) CreatePushPayload() *publishPushHelperBuilder

CreatePushPayload This method creates the push payload for use in the appropriate endpoint calls.

func (*PubNub) CreatePushPayloadWithContext

func (pn *PubNub) CreatePushPayloadWithContext(ctx Context) *publishPushHelperBuilder

CreatePushPayloadWithContext This method creates the push payload for use in the appropriate endpoint calls.

func (*PubNub) DeleteChannelGroup

func (pn *PubNub) DeleteChannelGroup() *deleteChannelGroupBuilder

DeleteChannelGroup This function removes the channel group.

func (*PubNub) DeleteChannelGroupWithContext

func (pn *PubNub) DeleteChannelGroupWithContext(ctx Context) *deleteChannelGroupBuilder

DeleteChannelGroupWithContext This function removes the channel group.

func (*PubNub) DeleteFile

func (pn *PubNub) DeleteFile() *deleteFileBuilder

DeleteFile Provides the ability to delete an individual file.

func (*PubNub) DeleteFileWithContext

func (pn *PubNub) DeleteFileWithContext(ctx Context) *deleteFileBuilder

DeleteFileWithContext Provides the ability to delete an individual file

func (*PubNub) DeleteMessages

func (pn *PubNub) DeleteMessages() *historyDeleteBuilder

DeleteMessages Removes the messages from the history of a specific channel.

func (*PubNub) DeleteMessagesWithContext

func (pn *PubNub) DeleteMessagesWithContext(ctx Context) *historyDeleteBuilder

DeleteMessagesWithContext Removes the messages from the history of a specific channel.

func (*PubNub) Destroy

func (pn *PubNub) Destroy()

Destroy stops all open requests, removes listeners, closes heartbeats, and cleans up.

func (*PubNub) DownloadFile

func (pn *PubNub) DownloadFile() *downloadFileBuilder

DownloadFile Provides the ability to fetch an individual file.

func (*PubNub) DownloadFileWithContext

func (pn *PubNub) DownloadFileWithContext(ctx Context) *downloadFileBuilder

DownloadFileWithContext Provides the ability to fetch an individual file.

func (*PubNub) Fetch

func (pn *PubNub) Fetch() *fetchBuilder

Fetch fetches historical messages from multiple channels.

func (*PubNub) FetchWithContext

func (pn *PubNub) FetchWithContext(ctx Context) *fetchBuilder

FetchWithContext fetches historical messages from multiple channels.

func (*PubNub) Fire

func (pn *PubNub) Fire() *fireBuilder

Fire endpoint allows the client to send a message to PubNub Functions Event Handlers. These messages will go directly to any Event Handlers registered on the channel that you fire to and will trigger their execution.

func (*PubNub) FireWithContext

func (pn *PubNub) FireWithContext(ctx Context) *fireBuilder

FireWithContext endpoint allows the client to send a message to PubNub Functions Event Handlers. These messages will go directly to any Event Handlers registered on the channel that you fire to and will trigger their execution.

func (*PubNub) GetAllChannelMetadata

func (pn *PubNub) GetAllChannelMetadata() *getAllChannelMetadataBuilder

GetAllChannelMetadata Returns a paginated list of Channel Metadata objects, optionally including the custom data object for each.

func (*PubNub) GetAllChannelMetadataWithContext

func (pn *PubNub) GetAllChannelMetadataWithContext(ctx Context) *getAllChannelMetadataBuilder

GetAllChannelMetadataWithContext Returns a paginated list of Channel Metadata objects, optionally including the custom data object for each.

func (*PubNub) GetAllUUIDMetadata

func (pn *PubNub) GetAllUUIDMetadata() *getAllUUIDMetadataBuilder

GetAllUUIDMetadata Returns a paginated list of UUID Metadata objects, optionally including the custom data object for each.

func (*PubNub) GetAllUUIDMetadataWithContext

func (pn *PubNub) GetAllUUIDMetadataWithContext(ctx Context) *getAllUUIDMetadataBuilder

GetAllUUIDMetadataWithContext Returns a paginated list of UUID Metadata objects, optionally including the custom data object for each.

func (*PubNub) GetChannelMembers

func (pn *PubNub) GetChannelMembers() *getChannelMembersBuilderV2

GetChannelMembers The method returns a list of members in a channel. The list will include user metadata for members that have additional metadata stored in the database.

func (*PubNub) GetChannelMembersWithContext

func (pn *PubNub) GetChannelMembersWithContext(ctx Context) *getChannelMembersBuilderV2

GetChannelMembersWithContext The method returns a list of members in a channel. The list will include user metadata for members that have additional metadata stored in the database.

func (*PubNub) GetChannelMetadata

func (pn *PubNub) GetChannelMetadata() *getChannelMetadataBuilder

GetChannelMetadata Returns metadata for the specified Channel, optionally including the custom data object for each.

func (*PubNub) GetChannelMetadataWithContext

func (pn *PubNub) GetChannelMetadataWithContext(ctx Context) *getChannelMetadataBuilder

GetChannelMetadataWithContext Returns metadata for the specified Channel, optionally including the custom data object for each.

func (*PubNub) GetClient

func (pn *PubNub) GetClient() *http.Client

GetClient Get a client for transactional requests (Non Subscribe).

func (*PubNub) GetFileURL

func (pn *PubNub) GetFileURL() *getFileURLBuilder

GetFileURL gets the URL of the file.

func (*PubNub) GetFileURLWithContext

func (pn *PubNub) GetFileURLWithContext(ctx Context) *getFileURLBuilder

GetFileURLWithContext gets the URL of the file.

func (*PubNub) GetListeners

func (pn *PubNub) GetListeners() map[*Listener]bool

GetListeners gets all the existing isteners.

func (*PubNub) GetMemberships

func (pn *PubNub) GetMemberships() *getMembershipsBuilderV2

GetMemberships The method returns a list of channel memberships for a user. This method doesn't return a user's subscriptions.

func (*PubNub) GetMembershipsWithContext

func (pn *PubNub) GetMembershipsWithContext(ctx Context) *getMembershipsBuilderV2

GetMembershipsWithContext The method returns a list of channel memberships for a user. This method doesn't return a user's subscriptions.

func (*PubNub) GetMessageActions

func (pn *PubNub) GetMessageActions() *getMessageActionsBuilder

GetMessageActions Get a list of message actions in a channel. Returns a list of actions in the response.

func (*PubNub) GetMessageActionsWithContext

func (pn *PubNub) GetMessageActionsWithContext(ctx Context) *getMessageActionsBuilder

GetMessageActionsWithContext Get a list of message actions in a channel. Returns a list of actions in the response.

func (*PubNub) GetState

func (pn *PubNub) GetState() *getStateBuilder

GetState The state API is used to set/get key/value pairs specific to a subscriber UUID. State information is supplied as a JSON object of key/value pairs.

func (*PubNub) GetStateWithContext

func (pn *PubNub) GetStateWithContext(ctx Context) *getStateBuilder

GetStateWithContext The state API is used to set/get key/value pairs specific to a subscriber UUID. State information is supplied as a JSON object of key/value pairs.

func (*PubNub) GetSubscribeClient

func (pn *PubNub) GetSubscribeClient() *http.Client

GetSubscribeClient Get a client for transactional requests.

func (*PubNub) GetSubscribedChannels

func (pn *PubNub) GetSubscribedChannels() []string

GetSubscribedChannels gets a list of all subscribed channels.

func (*PubNub) GetSubscribedGroups

func (pn *PubNub) GetSubscribedGroups() []string

GetSubscribedGroups gets a list of all subscribed channel groups.

func (*PubNub) GetToken

func (pn *PubNub) GetToken(resourceID string, resourceType PNResourceType) string

GetToken Returns the token for the specified resource type and ID. When no token is set for the resource ID, the method checks for a pattern token at the resource level. Returns nil if not found.

func (*PubNub) GetTokens

func (pn *PubNub) GetTokens() GrantResourcesWithPermissions

GetTokens Returns the token for the specified resource type and ID. When no token is set for the resource ID, the method checks for a pattern token at the resource level. Returns nil if not found.

func (*PubNub) GetTokensByResource

func (pn *PubNub) GetTokensByResource(resourceType PNResourceType) GrantResourcesWithPermissions

GetTokensByResource Returns the token(s) for the specified type. Returns nil if not found.

func (*PubNub) GetUUIDMetadata

func (pn *PubNub) GetUUIDMetadata() *getUUIDMetadataBuilder

GetUUIDMetadata Returns metadata for the specified UUID, optionally including the custom data object for each.

func (*PubNub) GetUUIDMetadataWithContext

func (pn *PubNub) GetUUIDMetadataWithContext(ctx Context) *getUUIDMetadataBuilder

GetUUIDMetadataWithContext Returns metadata for the specified UUID, optionally including the custom data object for each.

func (*PubNub) Grant

func (pn *PubNub) Grant() *grantBuilder

Grant This function establishes access permissions for PubNub Access Manager (PAM) by setting the read or write attribute to true. A grant with read or write set to false (or not included) will revoke any previous grants with read or write set to true.

func (*PubNub) GrantToken

func (pn *PubNub) GrantToken() *grantTokenBuilder

GrantToken Use the Grant Token method to generate an auth token with embedded access control lists. The client sends the auth token to PubNub along with each request.

func (*PubNub) GrantTokenWithContext

func (pn *PubNub) GrantTokenWithContext(ctx Context) *grantTokenBuilder

GrantTokenWithContext Use the Grant Token method to generate an auth token with embedded access control lists. The client sends the auth token to PubNub along with each request.

func (*PubNub) GrantWithContext

func (pn *PubNub) GrantWithContext(ctx Context) *grantBuilder

GrantWithContext This function establishes access permissions for PubNub Access Manager (PAM) by setting the read or write attribute to true. A grant with read or write set to false (or not included) will revoke any previous grants with read or write set to true.

func (*PubNub) Heartbeat

func (pn *PubNub) Heartbeat() *heartbeatBuilder

Heartbeat You can send presence heartbeat notifications without subscribing to a channel. These notifications are sent periodically and indicate whether a client is connected or not.

func (*PubNub) HeartbeatWithContext

func (pn *PubNub) HeartbeatWithContext(ctx Context) *heartbeatBuilder

HeartbeatWithContext You can send presence heartbeat notifications without subscribing to a channel. These notifications are sent periodically and indicate whether a client is connected or not.

func (*PubNub) HereNow

func (pn *PubNub) HereNow() *hereNowBuilder

HereNow You can obtain information about the current state of a channel including a list of unique user-ids currently subscribed to the channel and the total occupancy count of the channel by calling the HereNow() function in your application.

func (*PubNub) HereNowWithContext

func (pn *PubNub) HereNowWithContext(ctx Context) *hereNowBuilder

HereNowWithContext You can obtain information about the current state of a channel including a list of unique user-ids currently subscribed to the channel and the total occupancy count of the channel by calling the HereNow() function in your application.

func (*PubNub) History

func (pn *PubNub) History() *historyBuilder

History fetches historical messages of a channel.

func (*PubNub) HistoryWithContext

func (pn *PubNub) HistoryWithContext(ctx Context) *historyBuilder

HistoryWithContext fetches historical messages of a channel.

func (*PubNub) Leave

func (pn *PubNub) Leave() *leaveBuilder

Leave unsubscribes from a channel.

func (*PubNub) LeaveWithContext

func (pn *PubNub) LeaveWithContext(ctx Context) *leaveBuilder

LeaveWithContext unsubscribes from a channel.

func (*PubNub) ListChannelsInChannelGroup

func (pn *PubNub) ListChannelsInChannelGroup() *allChannelGroupBuilder

ListChannelsInChannelGroup This function lists all the channels of the channel group.

func (*PubNub) ListChannelsInChannelGroupWithContext

func (pn *PubNub) ListChannelsInChannelGroupWithContext(ctx Context) *allChannelGroupBuilder

ListChannelsInChannelGroupWithContext This function lists all the channels of the channel group.

func (*PubNub) ListFiles

func (pn *PubNub) ListFiles() *listFilesBuilder

ListFiles Provides the ability to fetch all files in a channel.

func (*PubNub) ListFilesWithContext

func (pn *PubNub) ListFilesWithContext(ctx Context) *listFilesBuilder

ListFilesWithContext Provides the ability to fetch all files in a channel.

func (*PubNub) ListPushProvisions

func (pn *PubNub) ListPushProvisions() *listPushProvisionsRequestBuilder

ListPushProvisions Request for all channels on which push notification has been enabled using specified pushToken.

func (*PubNub) ListPushProvisionsWithContext

func (pn *PubNub) ListPushProvisionsWithContext(ctx Context) *listPushProvisionsRequestBuilder

ListPushProvisionsWithContext Request for all channels on which push notification has been enabled using specified pushToken.

func (*PubNub) ManageChannelMembers

func (pn *PubNub) ManageChannelMembers() *manageChannelMembersBuilderV2

ManageChannelMembers The method Set and Remove channel memberships for a user.

func (*PubNub) ManageChannelMembersWithContext

func (pn *PubNub) ManageChannelMembersWithContext(ctx Context) *manageChannelMembersBuilderV2

ManageChannelMembersWithContext The method Set and Remove channel memberships for a user.

func (*PubNub) ManageMemberships

func (pn *PubNub) ManageMemberships() *manageMembershipsBuilderV2

ManageMemberships Manage the specified UUID's memberships. You can Add, Remove, and Update a UUID's memberships.

func (*PubNub) ManageMembershipsWithContext

func (pn *PubNub) ManageMembershipsWithContext(ctx Context) *manageMembershipsBuilderV2

ManageMembershipsWithContext Manage the specified UUID's memberships. You can Add, Remove, and Update a UUID's memberships.

func (*PubNub) MessageCounts

func (pn *PubNub) MessageCounts() *messageCountsBuilder

MessageCounts Returns the number of messages published on one or more channels since a given time.

func (*PubNub) MessageCountsWithContext

func (pn *PubNub) MessageCountsWithContext(ctx Context) *messageCountsBuilder

MessageCountsWithContext Returns the number of messages published on one or more channels since a given time.

func (*PubNub) Presence

func (pn *PubNub) Presence() *presenceBuilder

Presence lets you subscribe to a presence channel.

func (*PubNub) PresenceWithContext

func (pn *PubNub) PresenceWithContext(ctx Context) *presenceBuilder

PresenceWithContext lets you subscribe to a presence channel.

func (*PubNub) Publish

func (pn *PubNub) Publish() *publishBuilder

Publish is used to send a message to all subscribers of a channel.

func (*PubNub) PublishFileMessage

func (pn *PubNub) PublishFileMessage() *publishFileMessageBuilder

PublishFileMessage Provides the ability to publish the asccociated messages with the uploaded file in case of failure to auto publish. To be used only in the case of failure.

func (*PubNub) PublishFileMessageWithContext

func (pn *PubNub) PublishFileMessageWithContext(ctx Context) *publishFileMessageBuilder

PublishFileMessageWithContext Provides the ability to publish the asccociated messages with the uploaded file in case of failure to auto publish. To be used only in the case of failure.

func (*PubNub) PublishWithContext

func (pn *PubNub) PublishWithContext(ctx Context) *publishBuilder

PublishWithContext function is used to send a message to all subscribers of a channel.

func (*PubNub) RemoveAllPushNotifications

func (pn *PubNub) RemoveAllPushNotifications() *removeAllPushChannelsForDeviceBuilder

RemoveAllPushNotifications Disable push notifications from all channels registered with the specified pushToken.

func (*PubNub) RemoveAllPushNotificationsWithContext

func (pn *PubNub) RemoveAllPushNotificationsWithContext(ctx Context) *removeAllPushChannelsForDeviceBuilder

RemoveAllPushNotificationsWithContext Disable push notifications from all channels registered with the specified pushToken.

func (*PubNub) RemoveChannelFromChannelGroup

func (pn *PubNub) RemoveChannelFromChannelGroup() *removeChannelFromChannelGroupBuilder

RemoveChannelFromChannelGroup This function removes the channels from the channel group.

func (*PubNub) RemoveChannelFromChannelGroupWithContext

func (pn *PubNub) RemoveChannelFromChannelGroupWithContext(ctx Context) *removeChannelFromChannelGroupBuilder

RemoveChannelFromChannelGroupWithContext This function removes the channels from the channel group.

func (*PubNub) RemoveChannelMembers

func (pn *PubNub) RemoveChannelMembers() *removeChannelMembersBuilder

RemoveChannelMembers Remove members from a Channel.

func (*PubNub) RemoveChannelMembersWithContext

func (pn *PubNub) RemoveChannelMembersWithContext(ctx Context) *removeChannelMembersBuilder

RemoveChannelMembersWithContext Remove members from a Channel.

func (*PubNub) RemoveChannelMetadata

func (pn *PubNub) RemoveChannelMetadata() *removeChannelMetadataBuilder

RemoveChannelMetadata Removes the metadata from a specified channel.

func (*PubNub) RemoveChannelMetadataWithContext

func (pn *PubNub) RemoveChannelMetadataWithContext(ctx Context) *removeChannelMetadataBuilder

RemoveChannelMetadataWithContext Removes the metadata from a specified channel.

func (*PubNub) RemoveListener

func (pn *PubNub) RemoveListener(listener *Listener)

RemoveListener lets you remove new listener.

func (*PubNub) RemoveMemberships

func (pn *PubNub) RemoveMemberships() *removeMembershipsBuilder

RemoveMemberships Remove channel memberships for a UUID.

func (*PubNub) RemoveMembershipsWithContext

func (pn *PubNub) RemoveMembershipsWithContext(ctx Context) *removeMembershipsBuilder

RemoveMembershipsWithContext Remove channel memberships for a UUID.

func (*PubNub) RemoveMessageAction

func (pn *PubNub) RemoveMessageAction() *removeMessageActionsBuilder

RemoveMessageAction Remove a peviously added action on a published message. Returns an empty response.

func (*PubNub) RemoveMessageActionWithContext

func (pn *PubNub) RemoveMessageActionWithContext(ctx Context) *removeMessageActionsBuilder

RemoveMessageActionWithContext Remove a peviously added action on a published message. Returns an empty response.

func (*PubNub) RemovePushNotificationsFromChannels

func (pn *PubNub) RemovePushNotificationsFromChannels() *removeChannelsFromPushBuilder

RemovePushNotificationsFromChannels Disable push notifications on provided set of channels.

func (*PubNub) RemovePushNotificationsFromChannelsWithContext

func (pn *PubNub) RemovePushNotificationsFromChannelsWithContext(ctx Context) *removeChannelsFromPushBuilder

RemovePushNotificationsFromChannelsWithContext Disable push notifications on provided set of channels.

func (*PubNub) RemoveUUIDMetadata

func (pn *PubNub) RemoveUUIDMetadata() *removeUUIDMetadataBuilder

RemoveUUIDMetadata Removes the metadata from a specified UUID.

func (*PubNub) RemoveUUIDMetadataWithContext

func (pn *PubNub) RemoveUUIDMetadataWithContext(ctx Context) *removeUUIDMetadataBuilder

RemoveUUIDMetadataWithContext Removes the metadata from a specified UUID.

func (*PubNub) ResetTokenManager

func (pn *PubNub) ResetTokenManager()

ResetTokenManager resets the token manager.

func (*PubNub) SendFile

func (pn *PubNub) SendFile() *sendFileBuilder

SendFile Clients can use this SDK method to upload a file and publish it to other users in a channel.

func (*PubNub) SendFileWithContext

func (pn *PubNub) SendFileWithContext(ctx Context) *sendFileBuilder

SendFileWithContext Clients can use this SDK method to upload a file and publish it to other users in a channel.

func (*PubNub) SetChannelMembers

func (pn *PubNub) SetChannelMembers() *setChannelMembersBuilder

SetChannelMembers This method sets members in a channel.

func (*PubNub) SetChannelMembersWithContext

func (pn *PubNub) SetChannelMembersWithContext(ctx Context) *setChannelMembersBuilder

SetChannelMembersWithContext This method sets members in a channel.

func (*PubNub) SetChannelMetadata

func (pn *PubNub) SetChannelMetadata() *setChannelMetadataBuilder

SetChannelMetadata Set metadata for a Channel in the database, optionally including the custom data object for each.

func (*PubNub) SetChannelMetadataWithContext

func (pn *PubNub) SetChannelMetadataWithContext(ctx Context) *setChannelMetadataBuilder

SetChannelMetadataWithContext Set metadata for a Channel in the database, optionally including the custom data object for each.

func (*PubNub) SetClient

func (pn *PubNub) SetClient(c *http.Client)

SetClient Set a client for transactional requests (Non Subscribe).

func (*PubNub) SetMemberships

func (pn *PubNub) SetMemberships() *setMembershipsBuilder

SetMemberships Set channel memberships for a UUID.

func (*PubNub) SetMembershipsWithContext

func (pn *PubNub) SetMembershipsWithContext(ctx Context) *setMembershipsBuilder

SetMembershipsWithContext Set channel memberships for a UUID.

func (*PubNub) SetState

func (pn *PubNub) SetState() *setStateBuilder

SetState The state API is used to set/get key/value pairs specific to a subscriber UUID. State information is supplied as a JSON object of key/value pairs.

func (*PubNub) SetStateWithContext

func (pn *PubNub) SetStateWithContext(ctx Context) *setStateBuilder

SetStateWithContext The state API is used to set/get key/value pairs specific to a subscriber UUID. State information is supplied as a JSON object of key/value pairs.

func (*PubNub) SetSubscribeClient

func (pn *PubNub) SetSubscribeClient(client *http.Client)

SetSubscribeClient Set a client for transactional requests.

func (*PubNub) SetToken

func (pn *PubNub) SetToken(token string)

SetToken Stores a single token in the Token Management System for use in API calls.

func (*PubNub) SetTokens

func (pn *PubNub) SetTokens(tokens []string)

SetTokens Stores multiple tokens in the Token Management System for use in API calls.

func (*PubNub) SetUUIDMetadata

func (pn *PubNub) SetUUIDMetadata() *setUUIDMetadataBuilder

SetUUIDMetadata Set metadata for a UUID in the database, optionally including the custom data object for each.

func (*PubNub) SetUUIDMetadataWithContext

func (pn *PubNub) SetUUIDMetadataWithContext(ctx Context) *setUUIDMetadataBuilder

SetUUIDMetadataWithContext Set metadata for a UUID in the database, optionally including the custom data object for each.

func (*PubNub) Signal

func (pn *PubNub) Signal() *signalBuilder

Signal The signal() function is used to send a signal to all subscribers of a channel.

func (*PubNub) SignalWithContext

func (pn *PubNub) SignalWithContext(ctx Context) *signalBuilder

SignalWithContext The signal() function is used to send a signal to all subscribers of a channel.

func (*PubNub) Subscribe

func (pn *PubNub) Subscribe() *subscribeBuilder

Subscribe causes the client to create an open TCP socket to the PubNub Real-Time Network and begin listening for messages on a specified channel.

func (*PubNub) Time

func (pn *PubNub) Time() *timeBuilder

Time This function will return a 17 digit precision Unix epoch.

func (*PubNub) TimeWithContext

func (pn *PubNub) TimeWithContext(ctx Context) *timeBuilder

TimeWithContext This function will return a 17 digit precision Unix epoch.

func (*PubNub) Unsubscribe

func (pn *PubNub) Unsubscribe() *unsubscribeBuilder

Unsubscribe When subscribed to a single channel, this function causes the client to issue a leave from the channel and close any open socket to the PubNub Network. For multiplexed channels, the specified channel(s) will be removed and the socket remains open until there are no more channels remaining in the list.

func (*PubNub) UnsubscribeAll

func (pn *PubNub) UnsubscribeAll()

UnsubscribeAll Unsubscribe from all channels and all channel groups.

func (*PubNub) WhereNow

func (pn *PubNub) WhereNow() *whereNowBuilder

WhereNow You can obtain information about the current list of channels to which a UUID is subscribed to by calling the WhereNow() function in your application.

func (*PubNub) WhereNowWithContext

func (pn *PubNub) WhereNowWithContext(ctx Context) *whereNowBuilder

WhereNowWithContext You can obtain information about the current list of channels to which a UUID is subscribed to by calling the WhereNow() function in your application.

type PublishFileMessageResponse

type PublishFileMessageResponse struct {
	Timestamp int64
}

PublishFileMessageResponse is the response to PublishFileMessage request.

type PublishResponse

type PublishResponse struct {
	Timestamp int64
}

PublishResponse is the response after the execution on Publish and Fire operations.

type ReconnectionManager

type ReconnectionManager struct {
	sync.RWMutex

	ExponentialMultiplier       int
	FailedCalls                 int
	Milliseconds                int
	OnReconnection              func()
	OnMaxReconnectionExhaustion func()
	DoneTimer                   chan bool
	// contains filtered or unexported fields
}

ReconnectionManager is used to store the properties required in running the Reconnection Manager.

func (*ReconnectionManager) HandleOnMaxReconnectionExhaustion

func (m *ReconnectionManager) HandleOnMaxReconnectionExhaustion(handler func())

HandleOnMaxReconnectionExhaustion sets the handler that will be called when the max reconnection attempts are exhausted.

func (*ReconnectionManager) HandleReconnection

func (m *ReconnectionManager) HandleReconnection(handler func())

HandleReconnection sets the handler that will be called when the network reconnects after a disconnect.

type ReconnectionPolicy

type ReconnectionPolicy int

ReconnectionPolicy is used as an enum to catgorize the reconnection policies

const (
	// PNNonePolicy is to be used when selecting the no Reconnection Policy
	// ReconnectionPolicy is set in the config.
	PNNonePolicy ReconnectionPolicy = 1 + iota
	// PNLinearPolicy is to be used when selecting the Linear Reconnection Policy
	// ReconnectionPolicy is set in the config.
	PNLinearPolicy
	// PNExponentialPolicy is to be used when selecting the Exponential Reconnection Policy
	// ReconnectionPolicy is set in the config.
	PNExponentialPolicy
)

type RemoveAllPushChannelsForDeviceResponse

type RemoveAllPushChannelsForDeviceResponse struct{}

RemoveAllPushChannelsForDeviceResponse is the struct returned when the Execute function of RemoveAllPushNotifications is called.

type RemoveChannelFromChannelGroupResponse

type RemoveChannelFromChannelGroupResponse struct {
}

RemoveChannelFromChannelGroupResponse is the struct returned when the Execute function of RemoveChannelFromChannelGroup is called.

type RemoveChannelsFromPushResponse

type RemoveChannelsFromPushResponse struct{}

RemoveChannelsFromPushResponse is the struct returned when the Execute function of RemovePushNotificationsFromChannels is called.

type RequestWorkers

type RequestWorkers struct {
	Workers        []Worker
	WorkersChannel chan chan *JobQItem
	MaxWorkers     int
	Sem            chan bool
}

RequestWorkers is the type to store the workers info

func (*RequestWorkers) Close

func (p *RequestWorkers) Close()

Close closes the workers

func (*RequestWorkers) ReadQueue

func (p *RequestWorkers) ReadQueue(pubnub *PubNub)

ReadQueue reads the queue and passes on the job to the workers

func (*RequestWorkers) Start

func (p *RequestWorkers) Start(pubnub *PubNub, ctx Context)

Start starts the workers

type ResourcePermissions

type ResourcePermissions struct {
	Read   bool
	Write  bool
	Manage bool
	Delete bool
	Create bool
}

ResourcePermissions contains all the applicable perms for bitmask translations.

type ResponseInfo

type ResponseInfo struct {
	Operation        OperationType
	StatusCode       int
	TLSEnabled       bool
	Origin           string
	UUID             string
	AuthKey          string
	OriginalResponse *http.Response
}

ResponseInfo is used to store the properties in the response of an request.

type SetChannelMetadataBody

type SetChannelMetadataBody struct {
	Name        string                 `json:"name"`
	Description string                 `json:"description"`
	Custom      map[string]interface{} `json:"custom"`
}

SetChannelMetadataBody is the input to update space

type SetStateResponse

type SetStateResponse struct {
	State   interface{}
	Message string
}

SetStateResponse is the response returned when the Execute function of SetState is called.

type SetUUIDMetadataBody

type SetUUIDMetadataBody struct {
	Name       string                 `json:"name"`
	ExternalID string                 `json:"externalId"`
	ProfileURL string                 `json:"profileUrl"`
	Email      string                 `json:"email"`
	Custom     map[string]interface{} `json:"custom"`
}

SetUUIDMetadataBody is the input to update user

type SignalResponse

type SignalResponse struct {
	Timestamp int64
}

SignalResponse is the response to Signal request.

type StateManager

type StateManager struct {
	sync.RWMutex
	// contains filtered or unexported fields
}

StateManager is used to store the subscriptions types

type StateOperation

type StateOperation struct {
	// contains filtered or unexported fields
}

StateOperation is the types to store state op params

type StatusCategory

type StatusCategory int

StatusCategory is used as an enum to catgorize the various status events in the APIs lifecycle

const (
	// PNUnknownCategory as the StatusCategory means an unknown status category event occurred.
	PNUnknownCategory StatusCategory = 1 + iota
	// PNTimeoutCategory as the StatusCategory means the request timeout has reached.
	PNTimeoutCategory
	// PNConnectedCategory as the StatusCategory means the channel is subscribed to receive messages.
	PNConnectedCategory
	// PNDisconnectedCategory as the StatusCategory means a disconnection occurred due to network issues.
	PNDisconnectedCategory
	// PNCancelledCategory as the StatusCategory means the context was cancelled.
	PNCancelledCategory
	// PNLoopStopCategory as the StatusCategory means the subscribe loop was stopped.
	PNLoopStopCategory
	// PNAcknowledgmentCategory as the StatusCategory is the Acknowledgement of an operation (like Unsubscribe).
	PNAcknowledgmentCategory
	// PNBadRequestCategory as the StatusCategory means the request was malformed.
	PNBadRequestCategory
	// PNAccessDeniedCategory as the StatusCategory means that PAM is enabled and the channel is not granted R/W access.
	PNAccessDeniedCategory
	// PNNoStubMatchedCategory as the StatusCategory means an unknown status category event occurred.
	PNNoStubMatchedCategory
	// PNReconnectedCategory as the StatusCategory means that the network was reconnected (after a disconnection).
	// Applicable on for PNLinearPolicy and PNExponentialPolicy.
	PNReconnectedCategory
	// PNReconnectionAttemptsExhausted as the StatusCategory means that the reconnection attempts
	// to reconnect to the network were exhausted. All channels would be unsubscribed at this point.
	// Applicable on for PNLinearPolicy and PNExponentialPolicy.
	// Reconnection attempts are set in the config: MaximumReconnectionRetries.
	PNReconnectionAttemptsExhausted
	// PNRequestMessageCountExceededCategory is fired when the MessageQueueOverflowCount limit is exceeded by the number of messages received in a single subscribe request
	PNRequestMessageCountExceededCategory
)

func (StatusCategory) String

func (c StatusCategory) String() string

type StatusResponse

type StatusResponse struct {
	Error                 error
	Category              StatusCategory
	Operation             OperationType
	StatusCode            int
	TLSEnabled            bool
	UUID                  string
	AuthKey               string
	Origin                string
	OriginalResponse      string
	Request               string
	AffectedChannels      []string
	AffectedChannelGroups []string
	AdditionalData        interface{}
}

StatusResponse is used to store the usable properties in the response of an request.

type SubscribeOperation

type SubscribeOperation struct {
	Channels         []string
	ChannelGroups    []string
	PresenceEnabled  bool
	Timetoken        int64
	FilterExpression string
	State            map[string]interface{}
	QueryParam       map[string]string
}

SubscribeOperation is the type to store the subscribe op params

type SubscriptionItem

type SubscriptionItem struct {
	// contains filtered or unexported fields
}

SubscriptionItem is used to store the subscription item's properties.

type SubscriptionManager

type SubscriptionManager struct {
	sync.RWMutex
	// contains filtered or unexported fields
}

SubscriptionManager Events: - ConnectedCategory - after connection established - DisconnectedCategory - after subscription loop stops for any reason (no channels left or error happened) Unsubscribe When you unsubscribe from channel or channel group the following events happens: - LoopStopCategory - immediately when no more channels or channel groups left to subscribe - PNUnsubscribeOperation - after leave request was fulfilled and server is notified about unsubscibed items Announcement: Status, Message and Presence announcement happens in a distinct goroutine. It doesn't block subscribe loop. Keep in mind that each listener will receive the same pointer to a response object. You may wish to create a shallow copy of either the response or the response message by you own to not affect the other listeners. Heartbeat: - Heartbeat is enabled by default. - Default presence timeout is 0 seconds. - The first Heartbeat request will be scheduled to be executed after getHeartbeatInterval() seconds (default - 149).

func (*SubscriptionManager) AddListener

func (m *SubscriptionManager) AddListener(listener *Listener)

AddListener adds a new listener.

func (*SubscriptionManager) Destroy

func (m *SubscriptionManager) Destroy()

Destroy closes the subscription manager, listeners and reconnection manager instances.

func (*SubscriptionManager) Disconnect

func (m *SubscriptionManager) Disconnect()

Disconnect stops all open subscribe requests, timers, heartbeats and unsubscribes from all channels

func (*SubscriptionManager) GetListeners

func (m *SubscriptionManager) GetListeners() map[*Listener]bool

GetListeners gets all the listeners.

func (*SubscriptionManager) RemoveAllListeners

func (m *SubscriptionManager) RemoveAllListeners()

RemoveAllListeners removes all the listeners.

func (*SubscriptionManager) RemoveListener

func (m *SubscriptionManager) RemoveListener(listener *Listener)

RemoveListener removes the listener.

type TelemetryManager

type TelemetryManager struct {
	sync.RWMutex

	IsRunning bool
	// contains filtered or unexported fields
}

TelemetryManager is the struct to store the Telemetry details.

func (*TelemetryManager) CleanUpTelemetryData

func (m *TelemetryManager) CleanUpTelemetryData()

CleanUpTelemetryData cleans up telemetry data of all operations.

func (*TelemetryManager) OperationLatency

func (m *TelemetryManager) OperationLatency() map[string]string

OperationLatency returns a map of the stored latencies by operation.

func (*TelemetryManager) StoreLatency

func (m *TelemetryManager) StoreLatency(latency float64, t OperationType)

StoreLatency stores the latency values of the different operations.

type TimeResponse

type TimeResponse struct {
	Timetoken int64
}

TimeResponse is the response when Time call is executed.

type TokenManager

type TokenManager struct {
	sync.RWMutex
	Tokens GrantResourcesWithPermissions
	// contains filtered or unexported fields
}

TokenManager struct is used to for token manager operations

func (*TokenManager) CleanUp

func (m *TokenManager) CleanUp()

CleanUp resets the token manager

func (*TokenManager) GetAllTokens

func (m *TokenManager) GetAllTokens() GrantResourcesWithPermissions

GetAllTokens retrieves all the tokens from the token manager

func (*TokenManager) GetToken

func (m *TokenManager) GetToken(resourceID string, resourceType PNResourceType) string

GetToken first match for direct ids, if no match found use the first token from pattern match ignoring the regex (by design).

func (*TokenManager) GetTokensByResource

func (m *TokenManager) GetTokensByResource(resourceType PNResourceType) GrantResourcesWithPermissions

GetTokensByResource retrieves the tokens by PNResourceType from the token manager

func (*TokenManager) SetAuthParan

func (m *TokenManager) SetAuthParan(q *url.Values, resourceID string, resourceType PNResourceType)

SetAuthParan sets the auth param in the requests by retrieving the corresponding tokens from the token manager

func (*TokenManager) StoreToken

func (m *TokenManager) StoreToken(token string)

StoreToken Aceepts PAMv3 token format token to store in the token manager

func (*TokenManager) StoreTokens

func (m *TokenManager) StoreTokens(token []string)

StoreTokens Aceepts PAMv3 token format tokens to store in the token manager

type UnsubscribeOperation

type UnsubscribeOperation struct {
	Channels      []string
	ChannelGroups []string
	QueryParam    map[string]string
}

UnsubscribeOperation is the types to store unsubscribe op params

type UserSpacePermissions

type UserSpacePermissions struct {
	Read   bool
	Write  bool
	Manage bool
	Delete bool
	Create bool
}

UserSpacePermissions contains all the acceptable perms for Users and Spaces

type UserSpacePermissionsWithToken

type UserSpacePermissionsWithToken struct {
	Permissions  UserSpacePermissions
	BitMaskPerms int64
	Token        string
	Timestamp    int64
	TTL          int
}

UserSpacePermissionsWithToken is used for users/spaces resource type permissions

type WhereNowResponse

type WhereNowResponse struct {
	Channels []string
}

WhereNowResponse is the response of the WhereNow request. Contains channels info.

type Worker

type Worker struct {
	WorkersChannel chan chan *JobQItem
	JobChannel     chan *JobQItem
	// contains filtered or unexported fields
}

Worker is the type to store the worker info

func (Worker) Process

func (pw Worker) Process(pubnub *PubNub)

Process runs a goroutine for the worker

Source Files

Jump to

Keyboard shortcuts

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