Documentation
¶
Overview ¶
Package nc provides a MQTT client to connect to the Notification Centre server. MQTT could be viewed as an application layer version of TCP since it uses similar mechanisms to ensure message delivery.
Index ¶
- Variables
- type AcknowledgementPayload
- type ActionPayload
- type AttributePayload
- type CalculateRetryDelayForAttempt
- type Client
- type ClientBuilder
- type ConfirmationPayload
- type CredentialsGetter
- type DataPayload
- type EventPayload
- type MessagePayload
- type MetadataPayload
- type MqttClientBuilder
- type NotificationClient
- type NotificationPayload
- type RecPayload
Constants ¶
This section is empty.
Variables ¶
View Source
var ErrInvalidCredentials = fmt.Errorf("stored credentials are not valid")
Functions ¶
This section is empty.
Types ¶
type AcknowledgementPayload ¶
type ActionPayload ¶
type AttributePayload ¶
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
Client is a client for Notification center
func NewClient ¶
func NewClient( clientBuilder ClientBuilder, subjectInfo events.Publisher[string], subjectErr events.Publisher[error], subjectPeerUpdate events.Publisher[[]string], credsFetcher CredentialsGetter, ) *Client
NewClient is a constructor for a NC client
type ClientBuilder ¶
type ClientBuilder interface {
Build(opts *mqtt.ClientOptions) mqtt.Client
}
type ConfirmationPayload ¶
type ConfirmationPayload struct {
MessageID string `json:"message_id"`
}
type CredentialsGetter ¶
type CredentialsGetter struct {
// contains filtered or unexported fields
}
func NewCredsFetcher ¶
func NewCredsFetcher(api core.CredentialsAPI, cm config.Manager) CredentialsGetter
func (*CredentialsGetter) GetCredentialsFromAPI ¶
func (cf *CredentialsGetter) GetCredentialsFromAPI() (config.NCData, error)
GetCredentials fetches credentials from core API and saves them in local config
func (*CredentialsGetter) GetCredentialsFromConfig ¶
func (cf *CredentialsGetter) GetCredentialsFromConfig() (config.NCData, error)
GetCredentialsFromConfig loads credentials from local config
func (*CredentialsGetter) RevokeCredentials ¶
func (cf *CredentialsGetter) RevokeCredentials(purgeSession bool) (bool, error)
RevokeCredentials revokes credentials
type DataPayload ¶
type DataPayload struct { Event EventPayload `json:"event"` Metadata MetadataPayload `json:"metadata"` }
type EventPayload ¶
type EventPayload struct { Type string `json:"type"` Attributes AttributePayload `json:"attributes"` }
type MessagePayload ¶
type MessagePayload struct { Data DataPayload `json:"data"` Notification NotificationPayload `json:"notification"` }
type MetadataPayload ¶
type MqttClientBuilder ¶
type MqttClientBuilder struct{}
func (MqttClientBuilder) Build ¶
func (MqttClientBuilder) Build(opts *mqtt.ClientOptions) mqtt.Client
type NotificationClient ¶
type NotificationPayload ¶
type NotificationPayload struct { Title string `json:"title"` Body string `json:"body"` Actions []ActionPayload `json:"actions"` }
type RecPayload ¶
type RecPayload struct {
Message MessagePayload `json:"message"`
}
RecPayload defines a payload sent by a NC
Click to show internal directories.
Click to hide internal directories.