messaging

package
v0.0.0-...-96bc9f9 Latest Latest
Warning

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

Go to latest
Published: Mar 8, 2024 License: MIT Imports: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Client

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

Client default implementation of a messaging client

func New

func New(config Config) (*Client, error)

New create a new messaging client

func (*Client) Close

func (c *Client) Close() error

Close gracefully closes down the messaging cient

func (*Client) Register

func (c *Client) Register(cid string)

Register registers a conversation

func (*Client) Request

func (c *Client) Request(recipients []string, cid string, mtype string, data []byte, timeout time.Duration) (string, []byte, error)

Request sends a request to a specified identity and blocks until response is received

func (*Client) Send

func (c *Client) Send(recipients []string, mtype string, plaintext []byte) error

Send sends an encypted message to recipients

func (*Client) SendAsync

func (c *Client) SendAsync(recipients []string, mtype string, plaintext []byte, callback func(error))

SendAsync sends an encypted message to recipients asynchromously, returning the servers response via the provided callback

func (*Client) Start

func (c *Client) Start() bool

Start starts the connection with self network.

func (*Client) Subscribe

func (c *Client) Subscribe(msgType string, sub func(sender string, payload []byte))

Subscribe subscribes to a given message type @param {String} message type to subscribe to [authentication.RequestAuthentication| authentication.ResponseAuthentication|fact.RequestInformation|fact.ResponseInformation]

func (*Client) Wait

func (c *Client) Wait(cid string, timeout time.Duration) (string, []byte, error)

Wait waits for a response from a given conversation

type Config

type Config struct {
	SelfID       string
	DeviceID     string
	KeyID        string
	PrivateKey   ed25519.PrivateKey
	MessagingURL string
	APIURL       string
	Transport    Transport
	Storage      Storage
}

Config messaging configuration for connecting to self messaging

type Storage

type Storage interface {
	AccountOffset(inboxID string) (int64, error)
	Encrypt(from string, to []string, plaintext []byte) ([]byte, error)
	Decrypt(from, to string, offset int64, ciphertext []byte) ([]byte, error)
}

Storage the storage provider used to encrypt and decrypt messages

type Transport

type Transport interface {
	Send(recipients []string, mtype string, priority int, data []byte) error
	SendAsync(recipients []string, mtype string, priority int, data []byte, callback func(err error))
	Receive() ([]byte, string, int64, []byte, error)
	Close() error
}

Transport the stateful connection used to send and receive messages

Jump to

Keyboard shortcuts

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