Documentation ¶
Overview ¶
entities @author LanguageY++2013 2022/11/8 18:28 @company soulgame
entities @author LanguageY++2013 2022/11/10 09:48 @company soulgame
entities @author LanguageY++2013 2022/11/9 18:42 @company soulgame
entities @author LanguageY++2013 2022/11/9 18:31 @company soulgame
entities @author LanguageY++2013 2022/11/9 14:37 @company soulgame
entities @author LanguageY++2013 2022/11/8 09:49 @company soulgame
entities @author LanguageY++2013 2022/11/8 15:49 @company soulgame
entities @author LanguageY++2013 2022/11/9 18:30 @company soulgame
entities @author LanguageY++2013 2022/11/9 15:11 @company soulgame
entities @author LanguageY++2013 2022/11/8 18:31 @company soulgame
Index ¶
- Constants
- Variables
- func SetGameClient(cli open.FlexMatchGameClient)
- func SetPublisher(pub pubsub.Publisher)
- type BatchTicketProcessor
- type CombinationTickets
- type Match
- func (m *Match) AcceptMatch(ticketId string)
- func (m *Match) AcceptTickets() (ret []*open.MatchmakingTicket)
- func (m *Match) AllTickets() (tickets []*open.MatchmakingTicket)
- func (m *Match) BuildGameSessionInfo() *open.GameSessionConnectionInfo
- func (m *Match) CheckAccepted() bool
- func (m *Match) RejectMatch(ticketId string)
- func (m *Match) StartAccept(acceptanceTimeoutSeconds int64, placingMatchChan chan<- *Match)
- func (m *Match) StartGameSession()
- type Matchmaking
- func (e *Matchmaking) AcceptMatch(ticketId string, userId int64, acceptType open.AcceptanceType) (err error)
- func (e *Matchmaking) CleanUp()
- func (e *Matchmaking) DispatchBatches(batches []*[]*open.MatchmakingTicket)
- func (m *Matchmaking) EstimatedWaitTime() int64
- func (e *Matchmaking) MatchFind(matchId string) (match *Match, ok bool)
- func (e *Matchmaking) MatchInsert(match *Match)
- func (e *Matchmaking) MatchRemove(matchId string)
- func (e *Matchmaking) Reload(conf *open.MatchmakingConfiguration)
- func (m *Matchmaking) StopMatch(ticketId string) (err error)
- func (t *Matchmaking) TicketFind(ticketId string) (ticket *open.MatchmakingTicket, ok bool)
- func (e *Matchmaking) TicketInput(ticket *open.MatchmakingTicket) (err error)
- func (t *Matchmaking) TicketInsert(ticket *open.MatchmakingTicket)
- func (e *Matchmaking) TicketQueued(ticket *open.MatchmakingTicket) (err error)
- func (t *Matchmaking) TicketRemove(ticketId string)
- func (t *Matchmaking) TicketSave(ticket *open.MatchmakingTicket) error
- func (e *Matchmaking) TicketSearching(tickets []*open.MatchmakingTicket)
- func (e *Matchmaking) TicketWatch()
- type MatchmakingRule
- type MatchmakingRuleSetWrapper
- func (rs *MatchmakingRuleSetWrapper) CheckExpansionRule(ep *open.MatchmakingExpansionRule) (err error)
- func (rs *MatchmakingRuleSetWrapper) CheckExpansionRules() (err error)
- func (rsw *MatchmakingRuleSetWrapper) CheckParams() (err error)
- func (rs *MatchmakingRuleSetWrapper) CheckRule(rule *open.MatchmakingRule) (err error)
- func (rs *MatchmakingRuleSetWrapper) CheckRules() (err error)
- func (rs *MatchmakingRuleSetWrapper) CheckTeam(team *open.MatchmakingTeamConfiguration) (err error)
- func (rs *MatchmakingRuleSetWrapper) CheckTeams() (err error)
- func (rsw *MatchmakingRuleSetWrapper) DivideBatch(tickets []*open.MatchmakingTicket) (batches []*[]*open.MatchmakingTicket)
- func (rsw *MatchmakingRuleSetWrapper) GetPlayerAttributeType(attrName string) string
- func (rs *MatchmakingRuleSetWrapper) GetPropertyExpressionMeasurements(p *parser.PropertyExprParser, teams []*Team) (measurements []float64)
- func (rs *MatchmakingRuleSetWrapper) GetPropertyExpressionReferenceValue(p *parser.PropertyExprParser, teams []*Team) (referenceValue float64)
- func (rsw *MatchmakingRuleSetWrapper) Init()
- func (rsw *MatchmakingRuleSetWrapper) MaxDistance(ruleName string, maxDistance float64, tryTimes int, creationTime int64) (newMaxDistance float64, ok bool)
- type MeasurementResult
- type MeasurementValue
- type MockGameClient
- type Team
- type Ticket
- type TicketQueue
- type TicketQueueOption
Constants ¶
const ( AcceptanceCompletedReasonTimeOut = "TimeOut" AcceptanceCompletedReasonAcceptance = "Acceptance" AcceptanceCompletedReasonRejection = "Rejection" StatusReasonRejectMatch = "RejectMatch" StatusReasonCreateGameSessionFailed = "CreateGameSessionFailed" StatusReasonSearchingFailedBackfill = "SearchingFailedBackfill" StatusReasonMatchRejectBackfill = "MatchRejectBackfill" )
Variables ¶
var (
ErrOutOfTicketQueueSize = errors.New("out of ticket queue size")
)
Functions ¶
func SetPublisher ¶
Types ¶
type BatchTicketProcessor ¶
type BatchTicketProcessor struct { //媒介 Matchmaking *Matchmaking // contains filtered or unexported fields }
func MewBatchTicketProcessor ¶
func MewBatchTicketProcessor(Matchmaking *Matchmaking) *BatchTicketProcessor
func (*BatchTicketProcessor) EstimatedWaitTime ¶
func (proc *BatchTicketProcessor) EstimatedWaitTime() int64
EstimatedWaitTime 预计等待时间单位秒,不能低于保底值
func (*BatchTicketProcessor) Input ¶
func (proc *BatchTicketProcessor) Input(batch []*open.MatchmakingTicket)
type CombinationTickets ¶
type CombinationTickets struct {
// contains filtered or unexported fields
}
票据组合
type Match ¶
type Match struct { //匹配唯一ID MatchId string //当前的对局团队 Teams []*Team //创建时间 CreationTime int64 //对局会话连接信息 GameSessionConnectionInfo *open.GameSessionConnectionInfo // contains filtered or unexported fields }
func NewMatch ¶
func NewMatch(matchmaking *Matchmaking, matchTeams []*Team) (match *Match)
func (*Match) AcceptTickets ¶
func (m *Match) AcceptTickets() (ret []*open.MatchmakingTicket)
func (*Match) AllTickets ¶
func (m *Match) AllTickets() (tickets []*open.MatchmakingTicket)
AllTickets 所有票据
func (*Match) BuildGameSessionInfo ¶
func (m *Match) BuildGameSessionInfo() *open.GameSessionConnectionInfo
func (*Match) CheckAccepted ¶
CheckAccepted 检测对局团队内的所有成员是否均接受了对局
func (*Match) StartAccept ¶
StartAccept 开始接受用户接受状态检测协程
type Matchmaking ¶
type Matchmaking struct { //对局配置 Conf *open.MatchmakingConfiguration //票据队列 TicketQueue TicketQueue //票据批次处理器 (TODO:如何根据负载动态调整处理器的数量?) BatchTicketProcessors []*BatchTicketProcessor //匹配成功计数 MatchSucceedCounter int64 // contains filtered or unexported fields }
func NewMatchmaking ¶
func NewMatchmaking(conf *open.MatchmakingConfiguration) *Matchmaking
func (*Matchmaking) AcceptMatch ¶
func (e *Matchmaking) AcceptMatch(ticketId string, userId int64, acceptType open.AcceptanceType) (err error)
AcceptMatch 玩家接受对局
func (*Matchmaking) DispatchBatches ¶
func (e *Matchmaking) DispatchBatches(batches []*[]*open.MatchmakingTicket)
DispatchBatches 票据批次分派
func (*Matchmaking) EstimatedWaitTime ¶
func (m *Matchmaking) EstimatedWaitTime() int64
EstimatedWaitTime 预计耗时
func (*Matchmaking) MatchFind ¶
func (e *Matchmaking) MatchFind(matchId string) (match *Match, ok bool)
MatchFind 匹配查找
func (*Matchmaking) MatchInsert ¶
func (e *Matchmaking) MatchInsert(match *Match)
MatchInsert 对局数据插入
func (*Matchmaking) MatchRemove ¶
func (e *Matchmaking) MatchRemove(matchId string)
MatchRemove 匹配移除,接收匹配完成时调用(接受超时、全部接收、任意拒绝)
func (*Matchmaking) StopMatch ¶
func (m *Matchmaking) StopMatch(ticketId string) (err error)
StopMatch 停止/取消匹配
func (*Matchmaking) TicketFind ¶
func (t *Matchmaking) TicketFind(ticketId string) (ticket *open.MatchmakingTicket, ok bool)
TicketFind 票据查找
func (*Matchmaking) TicketInput ¶
func (e *Matchmaking) TicketInput(ticket *open.MatchmakingTicket) (err error)
TicketInput 票据输入
func (*Matchmaking) TicketInsert ¶
func (t *Matchmaking) TicketInsert(ticket *open.MatchmakingTicket)
TicketInsert 票据插入
func (*Matchmaking) TicketQueued ¶
func (e *Matchmaking) TicketQueued(ticket *open.MatchmakingTicket) (err error)
TicketQueued 票据入队列
func (*Matchmaking) TicketRemove ¶
func (t *Matchmaking) TicketRemove(ticketId string)
TicketRemove 票据删除
func (*Matchmaking) TicketSave ¶
func (t *Matchmaking) TicketSave(ticket *open.MatchmakingTicket) error
TicketSave 票据保存
func (*Matchmaking) TicketSearching ¶
func (e *Matchmaking) TicketSearching(tickets []*open.MatchmakingTicket)
func (*Matchmaking) TicketWatch ¶
func (e *Matchmaking) TicketWatch()
TicketWatch 信号监听:
- 票据输入
- 票据超时检测
- 关闭检测
type MatchmakingRule ¶
type MatchmakingRule struct { open.MatchmakingRule MeasurementsParser *parser.PropertyExprParser ReferenceValueParser *parser.PropertyExprParser }
type MatchmakingRuleSetWrapper ¶
type MatchmakingRuleSetWrapper struct { *open.MatchmakingRuleSet //对局所需成员数 MatchPlayerNum int32 // contains filtered or unexported fields }
func NewMatchmakingRuleSetWrapper ¶
func NewMatchmakingRuleSetWrapper(rs *open.MatchmakingRuleSet) *MatchmakingRuleSetWrapper
func (*MatchmakingRuleSetWrapper) CheckExpansionRule ¶
func (rs *MatchmakingRuleSetWrapper) CheckExpansionRule(ep *open.MatchmakingExpansionRule) (err error)
CheckExpansionRule 验证扩展规则
func (*MatchmakingRuleSetWrapper) CheckExpansionRules ¶
func (rs *MatchmakingRuleSetWrapper) CheckExpansionRules() (err error)
CheckExpansionRules 验证扩展规则列表
func (*MatchmakingRuleSetWrapper) CheckParams ¶
func (rsw *MatchmakingRuleSetWrapper) CheckParams() (err error)
func (*MatchmakingRuleSetWrapper) CheckRule ¶
func (rs *MatchmakingRuleSetWrapper) CheckRule(rule *open.MatchmakingRule) (err error)
CheckRule 验证规则
func (*MatchmakingRuleSetWrapper) CheckRules ¶
func (rs *MatchmakingRuleSetWrapper) CheckRules() (err error)
CheckRules 验证规则列表
func (*MatchmakingRuleSetWrapper) CheckTeam ¶
func (rs *MatchmakingRuleSetWrapper) CheckTeam(team *open.MatchmakingTeamConfiguration) (err error)
CheckRuleTeam 验证Team定义
func (*MatchmakingRuleSetWrapper) CheckTeams ¶
func (rs *MatchmakingRuleSetWrapper) CheckTeams() (err error)
func (*MatchmakingRuleSetWrapper) DivideBatch ¶
func (rsw *MatchmakingRuleSetWrapper) DivideBatch(tickets []*open.MatchmakingTicket) (batches []*[]*open.MatchmakingTicket)
DivideBatch划分批次
func (*MatchmakingRuleSetWrapper) GetPlayerAttributeType ¶
func (rsw *MatchmakingRuleSetWrapper) GetPlayerAttributeType(attrName string) string
GetPlayerAttributeType 获取玩家属性类型
func (*MatchmakingRuleSetWrapper) GetPropertyExpressionMeasurements ¶
func (rs *MatchmakingRuleSetWrapper) GetPropertyExpressionMeasurements(p *parser.PropertyExprParser, teams []*Team) (measurements []float64)
GetPropertyExpressionMeasurements 获取规则的属性表达式值的测量值
func (*MatchmakingRuleSetWrapper) GetPropertyExpressionReferenceValue ¶
func (rs *MatchmakingRuleSetWrapper) GetPropertyExpressionReferenceValue(p *parser.PropertyExprParser, teams []*Team) (referenceValue float64)
GetPropertyExpressionReferenceValue 获取规则的属性表达式值的参考值
func (*MatchmakingRuleSetWrapper) MaxDistance ¶
func (rsw *MatchmakingRuleSetWrapper) MaxDistance(ruleName string, maxDistance float64, tryTimes int, creationTime int64) (newMaxDistance float64, ok bool)
MaxDistance 根据扩展规则计算最大距离
type MeasurementResult ¶
type MeasurementResult struct { Aggregation string //聚合函数 min/max/avg时等于团队数量, 空时仅执行flatten, 等于所有选择的团队的玩家的数量 Values []*MeasurementValue }
测量值
type MeasurementValue ¶
type MeasurementValue struct {
// contains filtered or unexported fields
}
type MockGameClient ¶
type MockGameClient struct {
// contains filtered or unexported fields
}
func NewMockGameClient ¶
func NewMockGameClient() *MockGameClient
func (*MockGameClient) CreateGameSession ¶
func (c *MockGameClient) CreateGameSession(ctx context.Context, in *open.CreateGameSessionRequest, opts ...grpc.CallOption) (*open.CreateGameSessionResponse, error)
type Ticket ¶
type Ticket struct { *open.MatchmakingTicket // contains filtered or unexported fields }
Ticket 并发保护ticket
type TicketQueue ¶
type TicketQueue interface { //票据输入 Input(ticket *open.MatchmakingTicket) error //票据监听 Watch() }
func NewRealTicketQueue ¶
func NewRealTicketQueue(batchTicketChan chan<- []*open.MatchmakingTicket, batchMinTicketNum int32, opts ...TicketQueueOption) TicketQueue
type TicketQueueOption ¶
type TicketQueueOption func(q *realTicketQueue)
func WithTicketQueueTimeout ¶
func WithTicketQueueTimeout(timeoutSeconds int64) TicketQueueOption