Documentation
¶
Index ¶
- type CommonProvider
- func (cp *CommonProvider) AddRoom(r Room) error
- func (cp *CommonProvider) DelRoom(r Room) error
- func (cp *CommonProvider) GetConn() (interface{}, error)
- func (cp *CommonProvider) GetGameName() string
- func (cp *CommonProvider) GetID() string
- func (cp *CommonProvider) GetRoom(roomId int32) Room
- func (cp *CommonProvider) GetRooms() []Room
- type Provider
- type Room
- type RoomState
- type Storage
- type Token
- type User
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type CommonProvider ¶
type CommonProvider struct {
// contains filtered or unexported fields
}
CommonProvider has the basic functionality of a 'provider'
func NewCommonProvider ¶
func NewCommonProvider(conn interface{}, id string, gameName string) *CommonProvider
func (*CommonProvider) AddRoom ¶
func (cp *CommonProvider) AddRoom(r Room) error
func (*CommonProvider) DelRoom ¶
func (cp *CommonProvider) DelRoom(r Room) error
func (*CommonProvider) GetConn ¶
func (cp *CommonProvider) GetConn() (interface{}, error)
func (*CommonProvider) GetGameName ¶
func (cp *CommonProvider) GetGameName() string
func (*CommonProvider) GetID ¶
func (cp *CommonProvider) GetID() string
func (*CommonProvider) GetRoom ¶
func (cp *CommonProvider) GetRoom(roomId int32) Room
func (*CommonProvider) GetRooms ¶
func (cp *CommonProvider) GetRooms() []Room
type Provider ¶
type Provider interface {
GetConn() (interface{}, error)
GetID() string
GetGameName() string
GetRooms() []Room
GetRoom(int32) Room
AddRoom(Room) error
DelRoom(Room) error
}
Provider supports at least one kind of game, and connects to core server as there is a live connection, provider is always in-memory right now we just use CommonProvider. however, should we bind special methods to different provider? e.g. UnoProvider, TexasProvider are both derived from CommonProvider and they have some custom functions.
type Storage ¶
type Storage interface {
CreateRoom() (Room, error)
GetRooms() []Room
GetRoomsWithFilter(func(Room) bool) []Room
FindRoom(roomID int32) (Room, error)
DelRoom(roomID int32) error
CreateUser(userName string, passwd string) error
GetUsers() []User
FindUser(userName string, passwd string) (User, error)
DelUser(userName string) error
CreateToken(user User) (Token, error)
FindToken(key string) (Token, error)
DelToken(key string) error
RegisterProvider(Provider) error
GetProviders() []Provider
FindProvider(providerID string) (Provider, error)
FindProviderByGame(gameName string) []Provider
UnRegisterProvider(Provider) error
}
Storage is an abstract layer between data user and data store all the type is interface
type User ¶
type User interface {
// user info
GetUserName() string
GetDisplayName() string
SetDisplayName(string) error
SetPasswd(oldPasswd string, newPasswd string) error
// game
GetConn() (interface{}, error)
SetConn(interface{})
GetRoom() (Room, error)
SetRoom(Room) error
GetTemporaryID() uint32 // avoid exposing the username to provider
SetTemporaryID(uint32)
}
Click to show internal directories.
Click to hide internal directories.