signald

package
v0.0.0-...-e63f402 Latest Latest
Warning

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

Go to latest
Published: Jun 26, 2021 License: Apache-2.0 Imports: 5 Imported by: 0

Documentation

Overview

Package signald implements a simple client for the Signald protocol.

Index

Constants

View Source
const (
	DefaultPath = "/var/run/signald/signald.sock"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Client

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

Client represents a connection to a signald server.

func New

func New() (*Client, error)

New returns a client and attempts to connect on DefaultPath. If an error is returned the client is still valid and calling Encode will attempt to reconnect.

func NewPath

func NewPath(path string) (*Client, error)

NewPath is as new, but allows specifying the path to connect to.

func (*Client) Connect

func (c *Client) Connect() error

func (*Client) Connected

func (c *Client) Connected() bool

func (*Client) Decode

func (c *Client) Decode() (interface{}, error)

Decode message coming from signald

func (*Client) Disconnect

func (c *Client) Disconnect() error

func (*Client) Encode

func (c *Client) Encode(req interface{}) error

Encode message and write it to signald

type GetUser

type GetUser struct {
	Request
	Username         string      `json:"username"`
	RecipientAddress JsonAddress `json:"recipientAddress,omitempty"`
}

func (GetUser) New

func (s GetUser) New() interface{}

func (GetUser) Type

func (s GetUser) Type() string

type JSONAttachment

type JSONAttachment struct {
	ID             string `json:"id,omitempty"`
	Blurhash       string `json:"blurhash,omitempty"`
	Caption        string `json:"caption,omitempty"`
	ContentType    string `json:"contentType,omitempty"`
	CustomFilename string `json:"customFilename,omitempty"`
	Digest         string `json:"digest,omitempty"`
	Filename       string `json:"filename,omitempty"`
	Key            string `json:"key,omitempty"`
	Size           int    `json:"size,omitempty"`
	StoredFilename string `json:"storedFilename,omitempty"`
	VoiceNote      bool   `json:"voiceNote,omitempty"`
	Height         int    `json:"heigth,omitempty"`
	Width          int    `json:"width,omitempty"`
}

JSONAttachment to send with a message

type JsonAddress

type JsonAddress struct {
	Number string `json:"number"`
	Relay  string `json:"relay,omitempty"`
	UUID   string `json:"uuid,omitempty"`
}

type Message

type Message struct {
	Response
	Data map[string]interface{}
}

func (Message) New

func (s Message) New() interface{}

func (Message) Type

func (s Message) Type() string

type Quote

type Quote struct {
	ID     int         `json:"id"`
	Author JsonAddress `json:"author"`
	Text   string      `json:"text"`
}

type Request

type Request struct {
	Type    string `json:"type"`
	ID      string `json:"id"`
	Version string `json:"version"`
}

func (*Request) SetID

func (r *Request) SetID(id int)

func (*Request) SetType

func (r *Request) SetType(t string)

type Response

type Response struct {
	Type string `json:"type"`
	ID   string `json:"id"`
}

func (*Response) SetID

func (r *Response) SetID(id int)

func (*Response) SetType

func (r *Response) SetType(t string)

type Send

type Send struct {
	Request
	Username         string           `json:"username"`
	RecipientAddress JsonAddress      `json:"recipientAddress,omitempty"`
	RecipientGroupID string           `json:"recipientGroupId,omitempty"`
	MessageBody      string           `json:"messageBody"`
	Attachments      []JSONAttachment `json:"attachments,omitempty"`
	Quote            *Quote           `json:"quote,omitempty"`
}

Send message

func (Send) New

func (s Send) New() interface{}

func (Send) Type

func (s Send) Type() string

type Subscribe

type Subscribe struct {
	Request
	Username string `json:"username"`
}

func (Subscribe) New

func (s Subscribe) New() interface{}

func (Subscribe) Type

func (s Subscribe) Type() string

type Subscribed

type Subscribed struct {
	Response
	Data map[string]string
}

func (Subscribed) New

func (s Subscribed) New() interface{}

func (Subscribed) Type

func (s Subscribed) Type() string

type Typed

type Typed interface {
	Type() string
	SetType(string)
	SetID(int)
	New() interface{}
}

type User

type User struct {
	Response
	Data map[string]interface{}
}

func (User) New

func (s User) New() interface{}

func (User) Type

func (s User) Type() string

type Version

type Version struct {
	Response
	Data map[string]string
}

func (Version) New

func (s Version) New() interface{}

func (Version) Type

func (s Version) Type() string

Jump to

Keyboard shortcuts

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