Documentation
¶
Index ¶
- Variables
- func Encrypt(pword string) string
- func ValidateName(name string) bool
- type ClientData
- type DataAccess
- func (cdd *DataAccess) Authenticate(pword string) (bool, error)
- func (cdd *DataAccess) Block(name string) error
- func (cdd *DataAccess) BlockList() ([]string, error)
- func (cdd *DataAccess) ClientExists(name string) (bool, error)
- func (cdd *DataAccess) Friend(name string) error
- func (cdd *DataAccess) FriendList() ([]string, error)
- func (cdd *DataAccess) IsBlocked(name string) (bool, error)
- func (cdd *DataAccess) IsFriend(name string) (bool, error)
- func (cdd *DataAccess) LastOnline(name string) (time.Time, error)
- func (cdd *DataAccess) NewClient(pword string) error
- func (cdd *DataAccess) SetName(name string)
- func (cdd *DataAccess) Unblock(name string) error
- func (cdd *DataAccess) Unfriend(name string) error
- func (cdd *DataAccess) UpdateOnline(t time.Time) error
- type DataStore
- type Factory
Constants ¶
This section is empty.
Variables ¶
var ErrAccountCreationDisabled = errors.New("clientdata: New account creation has been disabled.")
var ErrBlocking = errors.New("clientdata: You are already blocking them.")
var ErrClientExists = errors.New("clientdata: Client already exists")
var ErrClientNotFound = errors.New("clientdata: Client not found.")
var ErrFriend = errors.New("clientdata: They are already on your friends list.")
var ErrInvalidName = errors.New("clientdata: Invalid Name.")
var ErrNotBlocking = errors.New("clientdata: You are not blocking them.")
var ErrNotFriend = errors.New("clientdata: They are not on your friends list.")
Functions ¶
func ValidateName ¶
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
}