biz

package
v0.0.0-...-771d5d4 Latest Latest
Warning

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

Go to latest
Published: Dec 5, 2024 License: MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

ProviderSet is biz providers.

Functions

func TranslateEmulatorKey

func TranslateEmulatorKey(key string) string

func TranslateKeyboardKey

func TranslateKeyboardKey(key string) string

Types

type AuthUseCase

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

func NewAuthUseCase

func NewAuthUseCase(ur UserRepo, c *conf.Auth, logger log.Logger) *AuthUseCase

func (*AuthUseCase) Login

func (uc *AuthUseCase) Login(ctx context.Context, username, password string) (string, error)

func (*AuthUseCase) Register

func (uc *AuthUseCase) Register(ctx context.Context, username, password string) error

type GameMetadata

type GameMetadata struct {
	Name      string `json:"name"`
	Mapper    string `json:"mapper"`
	Mirroring string `json:"mirroring"`
}

type GamingRepo

type GamingRepo interface {
	ListGames(ctx context.Context) ([]*GameMetadata, error)
	DeleteMemberConnection(ctx context.Context, roomId, userId int64, endpoint string) error
	RestartEmulator(ctx context.Context, roomId int64, game string, endpoint string) error
	ListSaves(ctx context.Context, roomId int64, page, pageSize int32) ([]*SaveMetadata, int32, error)
	SaveGame(ctx context.Context, roomId int64, endpoint string) error
	LoadSave(ctx context.Context, roomId, saveId int64, endpoint string) error
	DeleteSave(ctx context.Context, saveId int64, endpoint string) error
	GetServerICECandidate(ctx context.Context, roomId, userId int64, endpoint string) ([]string, error)
	GetGraphicOptions(ctx context.Context, roomId int64, endpoint string) (*GraphicOptions, error)
	SetGraphicOptions(ctx context.Context, roomId int64, options *GraphicOptions, endpoint string) error
	SetEmulatorSpeed(ctx context.Context, roomId int64, rate float64, endpoint string) (float64, error)
	GetEmulatorSpeed(ctx context.Context, roomId int64, endpoint string) (float64, error)
	ListSupportedEmulators(ctx context.Context) ([]*SupportedEmulator, error)
}

type GamingUseCase

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

func NewGamingUseCase

func NewGamingUseCase(roomRepo RoomRepo, gamingRepo GamingRepo, logger log.Logger) *GamingUseCase

func (*GamingUseCase) AddICECandidate

func (uc *GamingUseCase) AddICECandidate(ctx context.Context, roomId, userId int64, candidate string) error

func (*GamingUseCase) DeleteSave

func (uc *GamingUseCase) DeleteSave(ctx context.Context, roomId, saveId, userId int64) error

func (*GamingUseCase) GetEmulatorSpeed

func (uc *GamingUseCase) GetEmulatorSpeed(ctx context.Context, roomId int64) (float64, error)

func (*GamingUseCase) GetGraphicOptions

func (uc *GamingUseCase) GetGraphicOptions(ctx context.Context, roomId int64) (*GraphicOptions, error)

func (*GamingUseCase) GetServerICECandidate

func (uc *GamingUseCase) GetServerICECandidate(ctx context.Context, roomId, userId int64) ([]string, error)

func (*GamingUseCase) ListGames

func (uc *GamingUseCase) ListGames(ctx context.Context) ([]*GameMetadata, error)

func (*GamingUseCase) ListSaves

func (uc *GamingUseCase) ListSaves(ctx context.Context, roomId int64, page, pageSize int32) ([]*SaveMetadata, int32, error)

func (*GamingUseCase) ListSupportedEmulators

func (uc *GamingUseCase) ListSupportedEmulators(ctx context.Context) ([]*SupportedEmulator, error)

func (*GamingUseCase) LoadSave

func (uc *GamingUseCase) LoadSave(ctx context.Context, roomId, saveId int64, userId int64) error

func (*GamingUseCase) OpenGameConnection

func (uc *GamingUseCase) OpenGameConnection(ctx context.Context, roomId int64, userId int64, game string) (string, error)

func (*GamingUseCase) RestartEmulator

func (uc *GamingUseCase) RestartEmulator(ctx context.Context, roomId, userId int64, game string) error

func (*GamingUseCase) SDPAnswer

func (uc *GamingUseCase) SDPAnswer(ctx context.Context, roomId, userId int64, sdpAnswer string) error

func (*GamingUseCase) SaveGame

func (uc *GamingUseCase) SaveGame(ctx context.Context, roomId, userId int64) error

func (*GamingUseCase) SetController

func (uc *GamingUseCase) SetController(ctx context.Context, roomId, userId, playerId int64, controller int32) error

func (*GamingUseCase) SetEmulatorSpeed

func (uc *GamingUseCase) SetEmulatorSpeed(ctx context.Context, roomId, userId int64, rate float64) (float64, error)

func (*GamingUseCase) SetGraphicOptions

func (uc *GamingUseCase) SetGraphicOptions(ctx context.Context, roomId, userId int64, options *GraphicOptions) error

type GraphicOptions

type GraphicOptions struct {
	HighResOpen  bool `json:"highResOpen"`
	ReverseColor bool `json:"reverseColor"`
	Grayscale    bool `json:"grayscale"`
}

type JoinedRoom

type JoinedRoom struct {
	Room
	Role roomAPI.RoomRole `json:"role"`
}

type KeyboardBinding

type KeyboardBinding struct {
	KeyboardKey string
	EmulatorKey string
}

type LoginClaims

type LoginClaims struct {
	jwt.RegisteredClaims
	UserId   int64
	Username string
}

func (*LoginClaims) GetAudience

func (l *LoginClaims) GetAudience() (jwt.ClaimStrings, error)

func (*LoginClaims) GetExpirationTime

func (l *LoginClaims) GetExpirationTime() (*jwt.NumericDate, error)

func (*LoginClaims) GetIssuedAt

func (l *LoginClaims) GetIssuedAt() (*jwt.NumericDate, error)

func (*LoginClaims) GetIssuer

func (l *LoginClaims) GetIssuer() (string, error)

func (*LoginClaims) GetNotBefore

func (l *LoginClaims) GetNotBefore() (*jwt.NumericDate, error)

func (*LoginClaims) GetSubject

func (l *LoginClaims) GetSubject() (string, error)

type Macro

type Macro struct {
	Id          int64         `json:"id" bson:"id"`
	UserId      int64         `json:"userId" bson:"userId"`
	Name        string        `json:"name" bson:"name"`
	KeyboardKey string        `json:"keyboardKey" bson:"keyboardKey"`
	Actions     []MacroAction `json:"actions" bson:"actions"`
}

type MacroAction

type MacroAction struct {
	EmulatorKey  string `json:"emulatorKey" bson:"emulatorKey"`
	ReleaseDelay int64  `json:"releaseDelay" bson:"releaseDelay"`
}

type MacroRepo

type MacroRepo interface {
	CreateMacro(ctx context.Context, macro *Macro) error
	GetMacro(ctx context.Context, id int64) (*Macro, error)
	ListMacro(ctx context.Context, userId int64, page, pageSize int32) ([]*Macro, int32, error)
	DeleteMacro(ctx context.Context, id int64) error
}

type MacroUseCase

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

func NewMacroUseCase

func NewMacroUseCase(repo MacroRepo, logger log.Logger) *MacroUseCase

func (*MacroUseCase) CreateMacro

func (uc *MacroUseCase) CreateMacro(ctx context.Context, macro *Macro) error

func (*MacroUseCase) DeleteMacro

func (uc *MacroUseCase) DeleteMacro(ctx context.Context, id int64) error

func (*MacroUseCase) GetMacro

func (uc *MacroUseCase) GetMacro(ctx context.Context, id int64) (*Macro, error)

func (*MacroUseCase) ListMacro

func (uc *MacroUseCase) ListMacro(ctx context.Context, userId int64, page, pageSize int32) ([]*Macro, int32, error)

type Member

type Member struct {
	Id       int64            `json:"id"`
	Name     string           `json:"name"`
	Role     roomAPI.RoomRole `json:"role"`
	JoinedAt time.Time        `json:"joinedAt"`
	Player1  bool             `json:"player1"`
	Player2  bool             `json:"player2"`
}

type Room

type Room struct {
	Id           int64     `json:"id"`
	Name         string    `json:"name"`
	Host         int64     `json:"host"`
	HostName     string    `json:"hostName"`
	Private      bool      `json:"private"`
	MemberCount  int32     `json:"memberCount"`
	MemberLimit  int32     `json:"memberLimit"`
	Password     string    `json:"password"`
	CreateTime   time.Time `json:"createTime"`
	EmulatorType string    `json:"emulatorType"`
}

type RoomRepo

type RoomRepo interface {
	GetRoomSession(ctx context.Context, roomId int64) (*RoomSession, error)
	GetCreateRoomSession(ctx context.Context, roomId, userId int64, selectedGame string) (*RoomSession, error)
	CreateRoom(ctx context.Context, room *Room) error
	GetRoom(ctx context.Context, roomId int64) (*Room, error)
	ListJoinedRooms(ctx context.Context, userId int64, page, pageSize int) ([]*JoinedRoom, int, error)
	ListRooms(ctx context.Context, page, pageSize int) ([]*Room, int, error)
	ListMembers(ctx context.Context, roomId int64) ([]*Member, error)
	JoinRoom(ctx context.Context, roomId, userId int64, password string) error
	UpdateRoom(ctx context.Context, room *Room, userId int64) error
	DeleteRoom(ctx context.Context, roomId, userId int64) error
	GetRoomMember(ctx context.Context, roomId, userId int64) (*Member, error)
	UpdateMember(ctx context.Context, roomId, userId int64, role roomAPI.RoomRole) error
	DeleteMember(ctx context.Context, roomId, userId int64) error
}

type RoomSession

type RoomSession struct {
	RoomId   int64  `json:"roomId"`
	Endpoint string `json:"endpoint"`
}

type RoomUseCase

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

func NewRoomUseCase

func NewRoomUseCase(repo RoomRepo, ur UserRepo, gr GamingRepo, logger log.Logger) *RoomUseCase

func (*RoomUseCase) CreateRoom

func (uc *RoomUseCase) CreateRoom(ctx context.Context, name string, private bool, userId int64, emulatorType string) (*Room, error)

func (*RoomUseCase) DeleteMember

func (uc *RoomUseCase) DeleteMember(ctx context.Context, roomId, userId int64, operator int64) error

func (*RoomUseCase) DeleteRoom

func (uc *RoomUseCase) DeleteRoom(ctx context.Context, roomId, userId int64) error

func (*RoomUseCase) GetRoom

func (uc *RoomUseCase) GetRoom(ctx context.Context, roomId int64) (*Room, error)

func (*RoomUseCase) GetRoomMember

func (uc *RoomUseCase) GetRoomMember(ctx context.Context, roomId, userId int64) (*Member, error)

func (*RoomUseCase) JoinRoom

func (uc *RoomUseCase) JoinRoom(ctx context.Context, roomId, userId int64, password string) error

func (*RoomUseCase) ListJoinedRooms

func (uc *RoomUseCase) ListJoinedRooms(ctx context.Context, userId int64, page, pageSize int) ([]*JoinedRoom, int, error)

func (*RoomUseCase) ListMembers

func (uc *RoomUseCase) ListMembers(ctx context.Context, roomId int64) ([]*Member, error)

func (*RoomUseCase) ListRooms

func (uc *RoomUseCase) ListRooms(ctx context.Context, page, pageSize int) ([]*Room, int, error)

func (*RoomUseCase) UpdateMemberRole

func (uc *RoomUseCase) UpdateMemberRole(ctx context.Context, roomId, userId int64, role roomAPI.RoomRole, operator int64) error

func (*RoomUseCase) UpdateRoom

func (uc *RoomUseCase) UpdateRoom(ctx context.Context, room *Room, userId int64) error

type SaveMetadata

type SaveMetadata struct {
	Id         int64  `json:"id"`
	RoomId     int64  `json:"roomId"`
	Game       string `json:"game"`
	CreateTime int64  `json:"createTime"`
	ExitSave   bool   `json:"exitSave"`
}

type SupportedEmulator

type SupportedEmulator struct {
	Name                  string `json:"name"`
	SupportSaving         bool   `json:"saving"`
	SupportGraphicSetting bool   `json:"supportGraphicSetting"`
	Provider              string `json:"provider"`
	Games                 int32  `json:"games"`
}

type User

type User struct {
	ID       int64
	Name     string
	Password string
}

type UserKeyboardBinding

type UserKeyboardBinding struct {
	Id               int64
	Name             string
	UserId           int64
	KeyboardBindings []*KeyboardBinding
}

type UserKeyboardBindingRepo

type UserKeyboardBindingRepo interface {
	CreateKeyboardBinding(ctx context.Context, ub *UserKeyboardBinding) error
	UpdateKeyboardBinding(ctx context.Context, ub *UserKeyboardBinding) error
	DeleteKeyboardBinding(ctx context.Context, id int64) error
	GetKeyboardBinding(ctx context.Context, id int64) (*UserKeyboardBinding, error)
	ListUserKeyboardBinding(ctx context.Context, userId int64, page, pageSize int32) ([]*UserKeyboardBinding, int32, error)
}

type UserKeyboardBindingUseCase

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

func NewUserKeyboardBindingUseCase

func NewUserKeyboardBindingUseCase(repo UserKeyboardBindingRepo, logger log.Logger) *UserKeyboardBindingUseCase

func (*UserKeyboardBindingUseCase) Create

func (*UserKeyboardBindingUseCase) Delete

func (uc *UserKeyboardBindingUseCase) Delete(ctx context.Context, id, userId int64) error

func (*UserKeyboardBindingUseCase) Get

func (*UserKeyboardBindingUseCase) List

func (uc *UserKeyboardBindingUseCase) List(ctx context.Context, userId int64, page, pageSize int32) ([]*UserKeyboardBinding, int32, error)

func (*UserKeyboardBindingUseCase) Update

type UserRepo

type UserRepo interface {
	CreateUser(ctx context.Context, u *User) (*User, error)
	GetUser(ctx context.Context, id int64) (*User, error)
	GetUserByName(ctx context.Context, name string) (*User, error)
	VerifyPassword(ctx context.Context, name string, password string) error
}

type UserUseCase

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

func NewUserUseCase

func NewUserUseCase(ur UserRepo, logger log.Logger) *UserUseCase

func (*UserUseCase) GetUser

func (uc *UserUseCase) GetUser(ctx context.Context, id int64) (*User, error)

Jump to

Keyboard shortcuts

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