memory

package
v0.0.0-...-cea2a50 Latest Latest
Warning

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

Go to latest
Published: Apr 16, 2024 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

View Source
const (
	EmptyNickSigninError = "Can't signin User with empty nick"
	EmptyPassSigninError = "Can't signin User with empty password"
	EmptyNickLoginError  = "Can't login User with empty nick"
	EmptyPassLoginError  = "Can't login User with empty password"
)
View Source
const EmptyRoomNameError = "Room name could not be empty"

Variables

This section is empty.

Functions

This section is empty.

Types

type Message

type Message struct {
	Created  time.Time
	UserID   UserId
	RoomName string
	Payload  string
	ID       int
}

func (*Message) ConvertMessageToReading

func (mm *Message) ConvertMessageToReading() r.Message

type Role

type Role string
const (
	Member Role = "Member"
	Admin  Role = "Admin"
)

type Room

type Room struct {
	Created time.Time
	Name    string
	Members []UserId
}

type Storage

type Storage struct {
	Users    map[UserId]User
	Rooms    map[string]Room
	Messages map[int]Message
	*sync.RWMutex
}

func NewStorage

func NewStorage() Storage

func (*Storage) AddRoom

func (str *Storage) AddRoom(rn string) (string, error)

func (*Storage) AddUserToRoom

func (str *Storage) AddUserToRoom(name string, c *cht.Client) error

func (*Storage) ExcludeFromRoom

func (str *Storage) ExcludeFromRoom(roomName string, u *cht.Client) error

func (*Storage) LoginUser

func (str *Storage) LoginUser(lu auth.LoginUser) (string, error)

func (*Storage) ReadAuthUsers

func (str *Storage) ReadAuthUsers() []auth.AuthUser

func (*Storage) ReadRoom

func (str *Storage) ReadRoom(rid string) (rdn.Room, error)

func (*Storage) ReadRooms

func (str *Storage) ReadRooms() ([]rdn.Room, error)

func (*Storage) ReadUser

func (str *Storage) ReadUser(uid rdn.UserId) (rdn.User, error)

func (*Storage) ReadUsers

func (str *Storage) ReadUsers() ([]rdn.User, error)

func (*Storage) RoomHasUser

func (str *Storage) RoomHasUser(name string, c *cht.Client) (bool, int)

func (*Storage) SigninUser

func (str *Storage) SigninUser(su auth.SigninUser) (string, error)

func (*Storage) WriteMessage

func (str *Storage) WriteMessage(u *cht.Client, r *cht.Room, msg string) error

type User

type User struct {
	Created    time.Time
	Name       *string
	SecondName *string
	Email      *string
	Role       Role
	Nick       UserId
	Token      string
}

func ConvertUserFromSigning

func ConvertUserFromSigning(su auth.SigninUser) User

func (User) ConvertUserToReading

func (u User) ConvertUserToReading() r.User

func (*User) GetEmail

func (u *User) GetEmail() string

func (*User) GetName

func (u *User) GetName() string

func (*User) GetSecondName

func (u *User) GetSecondName() string

type UserId

type UserId string

func ConvertUserIdFromReading

func ConvertUserIdFromReading(rid r.UserId) UserId

func (UserId) ConvertUserIdToReading

func (muid UserId) ConvertUserIdToReading() r.UserId

Jump to

Keyboard shortcuts

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