clientdata

package
v0.0.0-...-4f83aec Latest Latest
Warning

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

Go to latest
Published: Apr 6, 2016 License: MIT Imports: 6 Imported by: 9

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrAccountCreationDisabled = errors.New("clientdata: New account creation has been disabled.")
View Source
var ErrBlocking = errors.New("clientdata: You are already blocking them.")
View Source
var ErrClientExists = errors.New("clientdata: Client already exists")
View Source
var ErrClientNotFound = errors.New("clientdata: Client not found.")
View Source
var ErrFriend = errors.New("clientdata: They are already on your friends list.")
View Source
var ErrInvalidName = errors.New("clientdata: Invalid Name.")
View Source
var ErrNotBlocking = errors.New("clientdata: You are not blocking them.")
View Source
var ErrNotFriend = errors.New("clientdata: They are not on your friends list.")

Functions

func Encrypt

func Encrypt(pword string) string

encrypt encrypts the password and returns the encrypted version.

func ValidateName

func ValidateName(name string) bool

ValidateName returns true if a name is only alphanumeric characters.

Types

type ClientData

type ClientData interface {
	Authenticate(pword string) (bool, error)
	ClientExists(name string) (bool, error)
	LastOnline(name string) (time.Time, error)
	UpdateOnline(t time.Time) error
	NewClient(pword string) error
	IsBlocked(name string) (bool, error)
	BlockList() ([]string, error)
	Block(name string) error
	Unblock(name string) error
	IsFriend(name string) (bool, error)
	Friend(name string) error
	Unfriend(name string) error
	FriendList() ([]string, error)
	SetName(name string)
}

ClientData is the interface used for interacting with the persistent client data.

type DataAccess

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

DataAccess is the default type of ClientData.

func NewDataAccess

func NewDataAccess(name string, data DataStore, disableNewAccounts bool) *DataAccess

NewDataAccess creates a new DataAccess. Names must be alphanumeric only.

func (*DataAccess) Authenticate

func (cdd *DataAccess) Authenticate(pword string) (bool, error)

Authenticate returns true if the password matches the clients password.

func (*DataAccess) Block

func (cdd *DataAccess) Block(name string) error

Block adds name to the clients blocklist.

func (*DataAccess) BlockList

func (cdd *DataAccess) BlockList() ([]string, error)

BlockList returns a list of names that the client is blocking.

func (*DataAccess) ClientExists

func (cdd *DataAccess) ClientExists(name string) (bool, error)

ClientExists returns true if a client with name is in the database

func (*DataAccess) Friend

func (cdd *DataAccess) Friend(name string) error

Friend adds name to the friend list.

func (*DataAccess) FriendList

func (cdd *DataAccess) FriendList() ([]string, error)

FriendList returns a [] of the names on the clients friend list.

func (*DataAccess) IsBlocked

func (cdd *DataAccess) IsBlocked(name string) (bool, error)

IsBlocked returns true if the client is blocking name.

func (*DataAccess) IsFriend

func (cdd *DataAccess) IsFriend(name string) (bool, error)

IsFriend returns true if name is in the friendlist

func (*DataAccess) LastOnline

func (cdd *DataAccess) LastOnline(name string) (time.Time, error)

LastOnline returns the clients lastonline entry.

func (*DataAccess) NewClient

func (cdd *DataAccess) NewClient(pword string) error

NewClient adds the client to the database with the provided password.

func (*DataAccess) SetName

func (cdd *DataAccess) SetName(name string)

SetName changes the name associated with this DataAccess object. Name must be alphanumeric only.

func (*DataAccess) Unblock

func (cdd *DataAccess) Unblock(name string) error

Unblock removes name from the client's blocklist. It will return ErrNotBlocking if name isn't on the client's blocklist.

func (*DataAccess) Unfriend

func (cdd *DataAccess) Unfriend(name string) error

Unfriend removes name from the friend list.

func (*DataAccess) UpdateOnline

func (cdd *DataAccess) UpdateOnline(t time.Time) error

UpdateOnline sets the clients lastonline to time.

type DataStore

type DataStore interface {
	Add(table string, values map[string]string) error
	Delete(table string, values map[string]string) error
	Get(table string, values map[string]string, columns ...string) ([]map[string]string, error)
	Set(table string, values, cond map[string]string) error
	Exists(table string, values map[string]string) (bool, error)
}

DataStore is the interface used by DataAccess to access stored data.

type Factory

type Factory interface {
	Create(name string) ClientData
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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