chat

package
v0.0.0-...-17ee918 Latest Latest
Warning

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

Go to latest
Published: Oct 23, 2020 License: MIT Imports: 4 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GenerateUID

func GenerateUID() (string, error)

GenerateUID generates an unique identifer suitable to be used by a chat Envelope. The UID is 128-bit number represented in base32, with a dot character separating each 5 digits, prefixed with 0v. For example: "0v5.acis6.788ro.bljvu.prn7k.22d4q".

Types

type Config

type Config struct {
	Length uint64
	Read   uint64
}

type Envelope

type Envelope struct {
	UID    string  `json:"uid"`
	Number uint64  `json:"number"`
	Author string  `json:"author"`
	When   float64 `json:"when"`
	Letter Letter  `json:"letter"`
}

type Inbox

type Inbox map[string]*Mailbox

type Letter

type Letter struct {
	Text *string `json:"text,omitempty"`
	URL  *string `json:"url,omitempty"`
	Code *struct {
		Expression string
		Output     [][]string
	} `json:"code,omitempty"`
	Me *string `json:"me,omitempty"`
}

type Mailbox

type Mailbox struct {
	Config    Config
	Envelopes []Envelope
}

type Message

type Message struct {
	Path     string   `json:"path"`
	Envelope Envelope `json:"envelope"`
}

type Messages

type Messages struct {
	Path      string     `json:"path"`
	Envelopes []Envelope `json:"envelopes"`
}

type Update

type Update struct {
	Initial  *Inbox    `json:"initial"`
	Keys     *[]string `json:"keys"`
	Messages *Messages `json:"messages"`

	Create *struct {
		Path string `json:"path"`
	} `json:"create"`

	Delete *struct {
		Path string `json:"path"`
	} `json:"delete"`

	Message *Message `json:"message"`

	Read *struct {
		Path string `json:"path"`
	} `json:"read"`
}

func ParseUpdate

func ParseUpdate(data []byte) (*Update, error)

parseUpdate will parse a JSON byte array of a chat-update message into a chat.Update type.

Jump to

Keyboard shortcuts

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