Documentation ¶
Index ¶
- Constants
- Variables
- type Connection
- type ConsumerResult
- type EndpointStats
- type GameFileMetadata
- type GameFileRepo
- type GameFileUseCase
- func (uc *GameFileUseCase) DeleteGames(ctx context.Context, games []string) (int, error)
- func (uc *GameFileUseCase) DeleteSave(ctx context.Context, saveId int64) error
- func (uc *GameFileUseCase) ListGames(ctx context.Context, page, pageSize int) ([]*GameFileMetadata, int, error)
- func (uc *GameFileUseCase) ListSaves(ctx context.Context, roomId int64, page, pageSize int32) ([]*GameSave, int32, error)
- func (uc *GameFileUseCase) UploadGameFile(ctx context.Context, game string, data []byte) error
- type GameInstance
- func (g *GameInstance) DeleteConnection(userId int64)
- func (g *GameInstance) DumpStats() *GameInstanceStats
- func (g *GameInstance) LoadSave(data []byte, game string, gameFileRepo GameFileRepo) error
- func (g *GameInstance) NewConnection(userId int64, stunServer string) (*Connection, string, error)
- func (g *GameInstance) RenderCallback(frame emulator.IFrame, logger *log.Helper)
- func (g *GameInstance) RestartEmulator(game string, gameData []byte) error
- func (g *GameInstance) SaveGame() (*GameSave, error)
- func (g *GameInstance) SetEmulatorSpeed(boostRate float64) float64
- func (g *GameInstance) SetGraphicOptions(options *GraphicOptions)
- type GameInstanceRepo
- type GameInstanceStats
- type GameInstanceUseCase
- func (uc *GameInstanceUseCase) CreateGameInstance(ctx context.Context, roomId int64, game string, emulatorType string) (*GameInstance, error)
- func (uc *GameInstanceUseCase) DeleteMemberConnection(ctx context.Context, roomId, userId int64) error
- func (uc *GameInstanceUseCase) GetController(ctx context.Context, roomId int64) (int64, int64, error)
- func (uc *GameInstanceUseCase) GetEmulatorSpeed(ctx context.Context, roomId int64) (float64, error)
- func (uc *GameInstanceUseCase) GetEndpointStats(ctx context.Context) (*EndpointStats, error)
- func (uc *GameInstanceUseCase) GetGameInstanceStats(ctx context.Context, roomId int64) (*GameInstanceStats, error)
- func (uc *GameInstanceUseCase) GetGraphicOptions(ctx context.Context, roomId int64) (*GraphicOptions, error)
- func (uc *GameInstanceUseCase) GetICECandidates(ctx context.Context, roomId, userId int64) ([]string, error)
- func (uc *GameInstanceUseCase) ICECandidate(ctx context.Context, roomId, userId int64, candidate string) error
- func (uc *GameInstanceUseCase) ListGameInstances(ctx context.Context) ([]*GameInstanceStats, error)
- func (uc *GameInstanceUseCase) ListSupportedEmulators(ctx context.Context) ([]*SupportedEmulator, error)
- func (uc *GameInstanceUseCase) LoadSave(ctx context.Context, saveId int64) error
- func (uc *GameInstanceUseCase) OnGameInstanceConnectionsAllClosed(instance *GameInstance)
- func (uc *GameInstanceUseCase) OpenGameConnection(ctx context.Context, roomId, userId int64) (string, error)
- func (uc *GameInstanceUseCase) ReleaseGameInstance(ctx context.Context, roomId int64, force bool) error
- func (uc *GameInstanceUseCase) RestartEmulator(ctx context.Context, roomId int64, game string) error
- func (uc *GameInstanceUseCase) SDPAnswer(ctx context.Context, roomId, userId int64, sdpAnswer string) error
- func (uc *GameInstanceUseCase) SaveGame(ctx context.Context, roomId int64) error
- func (uc *GameInstanceUseCase) SetController(ctx context.Context, roomId, playerId int64, controllerId int) error
- func (uc *GameInstanceUseCase) SetEmulatorSpeed(ctx context.Context, roomId int64, rate float64) (float64, error)
- func (uc *GameInstanceUseCase) SetGraphicOptions(ctx context.Context, roomId int64, options *GraphicOptions) error
- type GameSave
- type GraphicOptions
- type Message
- type RoomRepo
- type SupportedEmulator
Constants ¶
View Source
const ( MsgPlayerControlButtonPressed byte = iota MsgPlayerControlButtonReleased MsgChat MsgNewConn MsgCloseConn MsgSetController1 MsgSetController2 MsgResetController MsgPeerConnected MsgPauseEmulator MsgResumeEmulator MsgSaveGame MsgLoadSave MsgRestartEmulator MsgPing MsgSetGraphicOptions MsgSetEmulatorSpeed )
View Source
const ( InstanceStatusRunning int32 = iota InstanceStatusStopped )
View Source
const (
DefaultAudioSampleRate = 48000
)
View Source
const EnhanceFrameScale = 2
View Source
const (
MessageTargetEmulator int64 = iota
)
Variables ¶
View Source
var ProviderSet = wire.NewSet(NewGameInstanceUseCase, NewGameFileUseCase)
ProviderSet is biz providers.
Functions ¶
This section is empty.
Types ¶
type Connection ¶
type Connection struct {
// contains filtered or unexported fields
}
func (*Connection) Close ¶
func (c *Connection) Close()
func (*Connection) OnDataChannelMessage ¶
func (c *Connection) OnDataChannelMessage(instance *GameInstance, msg webrtc.DataChannelMessage)
func (*Connection) OnICEStateChange ¶
func (c *Connection) OnICEStateChange(_ webrtc.ICEConnectionState)
func (*Connection) OnPeerConnectionState ¶
func (c *Connection) OnPeerConnectionState(state webrtc.PeerConnectionState, instance *GameInstance)
type ConsumerResult ¶
type EndpointStats ¶
type GameFileMetadata ¶
type GameFileRepo ¶
type GameFileRepo interface { GetGameData(ctx context.Context, game string) ([]byte, error) UploadGameData(ctx context.Context, game string, data []byte, metadata *GameFileMetadata) error ListGames(ctx context.Context, page, pageSize int) ([]*GameFileMetadata, int, error) DeleteGames(ctx context.Context, games []string) (int, error) GetSavedGame(ctx context.Context, id int64) (*GameSave, error) SaveGame(ctx context.Context, save *GameSave) error ListSaves(ctx context.Context, roomId int64, page, pageSize int32) ([]*GameSave, int32, error) DeleteSave(ctx context.Context, saveId int64) error GetExitSave(ctx context.Context, roomId int64) (*GameSave, error) }
type GameFileUseCase ¶
type GameFileUseCase struct {
// contains filtered or unexported fields
}
func NewGameFileUseCase ¶
func NewGameFileUseCase(repo GameFileRepo, logger log.Logger) *GameFileUseCase
func (*GameFileUseCase) DeleteGames ¶
func (*GameFileUseCase) DeleteSave ¶
func (uc *GameFileUseCase) DeleteSave(ctx context.Context, saveId int64) error
func (*GameFileUseCase) ListGames ¶
func (uc *GameFileUseCase) ListGames(ctx context.Context, page, pageSize int) ([]*GameFileMetadata, int, error)
func (*GameFileUseCase) UploadGameFile ¶
type GameInstance ¶
type GameInstance struct { RoomId int64 EmulatorType string // 模拟器类型名称,比如nes LeaseID int64 InstanceId string // 实例ID // contains filtered or unexported fields }
func (*GameInstance) DeleteConnection ¶
func (g *GameInstance) DeleteConnection(userId int64)
func (*GameInstance) DumpStats ¶
func (g *GameInstance) DumpStats() *GameInstanceStats
func (*GameInstance) LoadSave ¶
func (g *GameInstance) LoadSave(data []byte, game string, gameFileRepo GameFileRepo) error
func (*GameInstance) NewConnection ¶
func (g *GameInstance) NewConnection(userId int64, stunServer string) (*Connection, string, error)
func (*GameInstance) RenderCallback ¶
func (g *GameInstance) RenderCallback(frame emulator.IFrame, logger *log.Helper)
func (*GameInstance) RestartEmulator ¶
func (g *GameInstance) RestartEmulator(game string, gameData []byte) error
func (*GameInstance) SaveGame ¶
func (g *GameInstance) SaveGame() (*GameSave, error)
func (*GameInstance) SetEmulatorSpeed ¶
func (g *GameInstance) SetEmulatorSpeed(boostRate float64) float64
func (*GameInstance) SetGraphicOptions ¶
func (g *GameInstance) SetGraphicOptions(options *GraphicOptions)
type GameInstanceRepo ¶
type GameInstanceRepo interface { CreateGameInstance(ctx context.Context, game *GameInstance) (int64, error) DeleteGameInstance(ctx context.Context, roomId int64) error GetGameInstance(ctx context.Context, roomId int64) (*GameInstance, error) ListGameInstances(ctx context.Context) ([]*GameInstance, error) }
type GameInstanceStats ¶
type GameInstanceUseCase ¶
type GameInstanceUseCase struct {
// contains filtered or unexported fields
}
func NewGameInstanceUseCase ¶
func NewGameInstanceUseCase(repo GameInstanceRepo, gameFileRepo GameFileRepo, roomRepo RoomRepo, c *conf.IceServer, logger log.Logger) *GameInstanceUseCase
func (*GameInstanceUseCase) CreateGameInstance ¶
func (uc *GameInstanceUseCase) CreateGameInstance(ctx context.Context, roomId int64, game string, emulatorType string) (*GameInstance, error)
CreateGameInstance 创建模拟器实例,第一个连接房间并创建会话的操作会创建模拟器实例 调用者必须持有房间会话的分布式锁,保证只创建一次
func (*GameInstanceUseCase) DeleteMemberConnection ¶
func (uc *GameInstanceUseCase) DeleteMemberConnection(ctx context.Context, roomId, userId int64) error
func (*GameInstanceUseCase) GetController ¶
func (*GameInstanceUseCase) GetEmulatorSpeed ¶
func (*GameInstanceUseCase) GetEndpointStats ¶
func (uc *GameInstanceUseCase) GetEndpointStats(ctx context.Context) (*EndpointStats, error)
func (*GameInstanceUseCase) GetGameInstanceStats ¶
func (uc *GameInstanceUseCase) GetGameInstanceStats(ctx context.Context, roomId int64) (*GameInstanceStats, error)
func (*GameInstanceUseCase) GetGraphicOptions ¶
func (uc *GameInstanceUseCase) GetGraphicOptions(ctx context.Context, roomId int64) (*GraphicOptions, error)
func (*GameInstanceUseCase) GetICECandidates ¶
func (*GameInstanceUseCase) ICECandidate ¶
func (*GameInstanceUseCase) ListGameInstances ¶
func (uc *GameInstanceUseCase) ListGameInstances(ctx context.Context) ([]*GameInstanceStats, error)
func (*GameInstanceUseCase) ListSupportedEmulators ¶
func (uc *GameInstanceUseCase) ListSupportedEmulators(ctx context.Context) ([]*SupportedEmulator, error)
func (*GameInstanceUseCase) LoadSave ¶
func (uc *GameInstanceUseCase) LoadSave(ctx context.Context, saveId int64) error
func (*GameInstanceUseCase) OnGameInstanceConnectionsAllClosed ¶
func (uc *GameInstanceUseCase) OnGameInstanceConnectionsAllClosed(instance *GameInstance)
func (*GameInstanceUseCase) OpenGameConnection ¶
func (*GameInstanceUseCase) ReleaseGameInstance ¶
func (uc *GameInstanceUseCase) ReleaseGameInstance(ctx context.Context, roomId int64, force bool) error
ReleaseGameInstance 释放模拟器实例,所有连接断开后延迟释放 调用者必须持有房间会话的分布式锁,保证没有新连接建立
func (*GameInstanceUseCase) RestartEmulator ¶
func (*GameInstanceUseCase) SaveGame ¶
func (uc *GameInstanceUseCase) SaveGame(ctx context.Context, roomId int64) error
func (*GameInstanceUseCase) SetController ¶
func (*GameInstanceUseCase) SetEmulatorSpeed ¶
func (*GameInstanceUseCase) SetGraphicOptions ¶
func (uc *GameInstanceUseCase) SetGraphicOptions(ctx context.Context, roomId int64, options *GraphicOptions) error
type GraphicOptions ¶
Click to show internal directories.
Click to hide internal directories.