model

package
Version: v0.0.0-...-84203ce Latest Latest
Warning

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

Go to latest
Published: Sep 20, 2021 License: MIT, Unlicense Imports: 6 Imported by: 0

Documentation

Overview

Package model provides the domain-specific data models for this list.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type DateBoundary

type DateBoundary struct {
	Date time.Time
}

DateBoundary represents a change in the date during a chat.

func (DateBoundary) Serial

func (d DateBoundary) Serial() list.Serial

Serial returns the unique identifier of the message.

type Message

type Message struct {
	SerialID                string
	Sender, Content, Status string
	SentAt                  time.Time
	Image                   string
	Avatar                  string
	Read                    bool
}

Message represents a chat message.

func (Message) Serial

func (m Message) Serial() list.Serial

Serial returns the unique identifier for this message.

type Room

type Room struct {
	// Image avatar for the room.
	Image image.Image
	// Name of the room.
	Name string
	// Latest message in the room, if any.
	Latest *Message
	// Composing is a set of users in this room currently composing a message.
	Composing sync.Map
}

Room is a unique conversation context. Room can have any number of participants, and any number of messages. Any participant of a room should be able to view the room, send messages to and recieve messages from the other participants.

func (*Room) SetComposing

func (r *Room) SetComposing(user string, isComposing bool)

SetComposing sets the composing status of a user for this room.

type Rooms

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

Rooms structure manages a collection of rooms.

func (*Rooms) Add

func (r *Rooms) Add(room Room)

Add room to collection.

func (*Rooms) List

func (r *Rooms) List() (list []*Room)

List returns an ordered list of room data.

func (*Rooms) Lookup

func (r *Rooms) Lookup(name string) (*Room, bool)

Lookup room by name.

func (*Rooms) Random

func (r *Rooms) Random() *Room

Random returns a randomly selected room from the collection. If there are no rooms, nil is returned.

type Theme

type Theme int

Theme enumerates the various 9patch themes.

const (
	ThemeEmpty Theme = iota
	ThemePlatoCookie
	ThemeHotdog
)

type UnreadBoundary

type UnreadBoundary struct{}

UnreadBoundary represents the boundary between the last read message in a chat and the next unread message.

func (UnreadBoundary) Serial

func (u UnreadBoundary) Serial() list.Serial

Serial returns the unique identifier for the boundary.

type User

type User struct {
	// Name of user.
	Name string
	// Avatar is url to the image of the user.
	Avatar string
	// Theme specifies the name of a 9patch theme to use for messages from this
	// user. If theme is specified it will be the preferred message surface.
	// Empty string indicates no theme.
	Theme Theme
	// Color to use for message bubbles of messages from this user.
	Color color.NRGBA
}

User is a unique identity that can send messages and participate in rooms.

type Users

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

Users structure manages a collection of user data.

func (*Users) Add

func (us *Users) Add(u User)

Add user to collection.

func (*Users) List

func (us *Users) List() (list []*User)

List returns an ordered list of user data.

func (*Users) Lookup

func (us *Users) Lookup(name string) (*User, bool)

Lookup user by name.

func (*Users) Random

func (us *Users) Random() *User

Random returns a randomly selected user from the collection. If there are no users, nil is returned.

Source Files

Jump to

Keyboard shortcuts

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