Documentation
¶
Overview ¶
Package sdk is the Go game server sdk.
Index ¶
Constants ¶
View Source
const (
GameServerStatusAllocated = "Allocated"
)
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type GameServerCallback ¶
type GameServerCallback func(gs *sdk.GameServer)
type MultiverseSDK ¶ added in v1.0.6
type MultiverseSDK interface {
// Ready 标记 game server 为 ready 状态
Ready() error
// GetAllocationEnvs 获取启动配置里配置的和Allocation 接口传过来的环境变量
GetAllocationEnvs() (map[string]string, error)
// GetServerInfo 获取server 基础配置信息,如 ip, port, allocationId等信息
GetServerInfo() (*ServerInfo, error)
// GetExpireAt 获取当前 game server 到期时间
GetExpireAt() (int64, error)
// Shutdown 关闭 game server
Shutdown() error
// Allocate 标记 game server 为 allocated 状态, 舰队模式可用该方法来分配 game server
Allocate() error
// WatchGameServer watch game server status, 舰队模式可用该方法监听 game server到 allocated 状态
WatchGameServer(GameServerCallback) error
// SetResources ResetResources 可在运行过程动态调整 cpu 配置,为高级功能,如需使用,请联系我们
SetResources(resources *sdk.Resources) error
ResetResources() error
// ExtendTTL 延长当前 game server 到期时间
// params: ttl 格式示例 30m, 1h
// 此方法为高级功能,如需使用,请联系我们
ExtendTTL(ttl string) error
}
func GetInstance ¶ added in v1.0.6
func GetInstance() (MultiverseSDK, error)
type ServerInfo ¶ added in v1.0.6
type ServerInfo struct {
AppId string
ProfileId string
Ip string
GamePorts []*sdk.GameServer_Status_Port
// 舰队模式下需等到 game server 为 allocated 状态方才有值
AllocationId string
// 开启房间服务后,此项才有值,且舰队模式同AllocationId
RoomId string
// 是否是测试服务器(通过前端启动配置界面开启的server为测试服务器),
// 测试服务器无 AllocationId, RoomId 等数据,
// 可通过该参数判断是否是测试服务器,进一步控制对其他方法的调用,
// 比如 GetExpireAt 方法就无法在测试服务器中调用.
IsTestServer bool
}
Source Files
¶
- consts.go
- models.go
- sdk.go
Click to show internal directories.
Click to hide internal directories.