Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Add extension point for CanJoinMatchmakeSession #42

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion matchmake-extension/join_matchmake_session.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,12 @@ func (commonProtocol *CommonProtocol) joinMatchmakeSession(err error, packet nex
return nil, nex.NewError(nex.ResultCodes.RendezVous.PermissionDenied, "change_error")
}

nexError = common_globals.CanJoinMatchmakeSession(commonProtocol.manager, connection.PID(), joinedMatchmakeSession)
// * Allow game servers to do their own permissions checks
if commonProtocol.CanJoinMatchmakeSession != nil {
nexError = commonProtocol.CanJoinMatchmakeSession(commonProtocol.manager, connection.PID(), joinedMatchmakeSession)
} else {
nexError = common_globals.CanJoinMatchmakeSession(commonProtocol.manager, connection.PID(), joinedMatchmakeSession)
}
if nexError != nil {
commonProtocol.manager.Mutex.Unlock()
return nil, nexError
Expand Down
7 changes: 6 additions & 1 deletion matchmake-extension/join_matchmake_session_ex.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,12 @@ func (commonProtocol *CommonProtocol) joinMatchmakeSessionEx(err error, packet n
return nil, nex.NewError(nex.ResultCodes.RendezVous.PermissionDenied, "change_error")
}

nexError = common_globals.CanJoinMatchmakeSession(commonProtocol.manager, connection.PID(), joinedMatchmakeSession)
// * Allow game servers to do their own permissions checks
if commonProtocol.CanJoinMatchmakeSession != nil {
nexError = commonProtocol.CanJoinMatchmakeSession(commonProtocol.manager, connection.PID(), joinedMatchmakeSession)
} else {
nexError = common_globals.CanJoinMatchmakeSession(commonProtocol.manager, connection.PID(), joinedMatchmakeSession)
}
if nexError != nil {
commonProtocol.manager.Mutex.Unlock()
return nil, nexError
Expand Down
7 changes: 6 additions & 1 deletion matchmake-extension/join_matchmake_session_with_param.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,12 @@ func (commonProtocol *CommonProtocol) joinMatchmakeSessionWithParam(err error, p
return nil, nex.NewError(nex.ResultCodes.RendezVous.InvalidPassword, "change_error")
}

nexError = common_globals.CanJoinMatchmakeSession(commonProtocol.manager, connection.PID(), joinedMatchmakeSession)
// * Allow game servers to do their own permissions checks
if commonProtocol.CanJoinMatchmakeSession != nil {
nexError = commonProtocol.CanJoinMatchmakeSession(commonProtocol.manager, connection.PID(), joinedMatchmakeSession)
} else {
nexError = common_globals.CanJoinMatchmakeSession(commonProtocol.manager, connection.PID(), joinedMatchmakeSession)
}
if nexError != nil {
commonProtocol.manager.Mutex.Unlock()
return nil, nexError
Expand Down
1 change: 1 addition & 0 deletions matchmake-extension/protocol.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ type CommonProtocol struct {
endpoint nex.EndpointInterface
protocol matchmake_extension.Interface
manager *common_globals.MatchmakingManager
CanJoinMatchmakeSession func(manager *common_globals.MatchmakingManager, pid *types.PID, matchmakeSession *match_making_types.MatchmakeSession) *nex.Error
CleanupSearchMatchmakeSession func(matchmakeSession *match_making_types.MatchmakeSession)
CleanupMatchmakeSessionSearchCriterias func(searchCriterias *types.List[*match_making_types.MatchmakeSessionSearchCriteria])
OnAfterOpenParticipation func(packet nex.PacketInterface, gid *types.PrimitiveU32)
Expand Down