feat!(secure): Use new MatchmakingManager code

Port to the nex-protocols-common-go/matchmaking-rewrite staging branch. This has better notification behaviour, among other improvements.
This commit is contained in:
Ash Logan 2024-08-10 16:56:52 +10:00
parent 8a30e47281
commit 75d247ceb1
4 changed files with 22 additions and 2 deletions

View File

@ -1,8 +1,10 @@
package globals
import (
"database/sql"
pb "github.com/PretendoNetwork/grpc-go/account"
"github.com/PretendoNetwork/nex-go/v2"
"github.com/PretendoNetwork/nex-protocols-common-go/v2/globals"
"github.com/PretendoNetwork/plogger-go"
"google.golang.org/grpc"
"google.golang.org/grpc/metadata"
@ -17,6 +19,9 @@ var AuthenticationEndpoint *nex.PRUDPEndPoint
var SecureServer *nex.PRUDPServer
var SecureEndpoint *nex.PRUDPEndPoint
var Postgres *sql.DB
var MatchmakingManager *common_globals.MatchmakingManager
var GRPCAccountClientConnection *grpc.ClientConn
var GRPCAccountClient pb.AccountClient
var GRPCAccountCommonMetadata metadata.MD

View File

@ -1,6 +1,7 @@
package main
import (
"database/sql"
"fmt"
"os"
"strconv"
@ -104,4 +105,12 @@ func init() {
globals.GRPCAccountCommonMetadata = metadata.Pairs(
"X-API-Key", accountGRPCAPIKey,
)
globals.Postgres, err = sql.Open("postgres", os.Getenv("PN_MINECRAFT_POSTGRES_URI"))
if err != nil {
globals.Logger.Critical(err.Error())
}
globals.Logger.Success("Connected to Postgres!")
}

View File

@ -82,15 +82,18 @@ func registerCommonSecureServerProtocols() {
matchMakingProtocol := matchmaking.NewProtocol()
globals.SecureEndpoint.RegisterServiceProtocol(matchMakingProtocol)
commonmatchmaking.NewCommonProtocol(matchMakingProtocol)
commonMatchMakingProtocol := commonmatchmaking.NewCommonProtocol(matchMakingProtocol)
commonMatchMakingProtocol.SetManager(globals.MatchmakingManager)
matchMakingExtProtocol := matchmakingext.NewProtocol()
globals.SecureEndpoint.RegisterServiceProtocol(matchMakingExtProtocol)
commonmatchmakingext.NewCommonProtocol(matchMakingExtProtocol)
commonMatchMakingExtProtocol := commonmatchmakingext.NewCommonProtocol(matchMakingExtProtocol)
commonMatchMakingExtProtocol.SetManager(globals.MatchmakingManager)
matchmakeExtensionProtocol := matchmakeextension.NewProtocol()
globals.SecureEndpoint.RegisterServiceProtocol(matchmakeExtensionProtocol)
commonMatchmakeExtensionProtocol := commonmatchmakeextension.NewCommonProtocol(matchmakeExtensionProtocol)
commonMatchmakeExtensionProtocol.SetManager(globals.MatchmakingManager)
commonMatchmakeExtensionProtocol.CleanupSearchMatchmakeSession = cleanupSearchMatchmakeSessionHandler
if os.Getenv("PN_MINECRAFT_ALLOW_PUBLIC_MATCHMAKING") != "1" {

View File

@ -2,6 +2,7 @@ package nex
import (
"fmt"
common_globals "github.com/PretendoNetwork/nex-protocols-common-go/v2/globals"
"os"
"strconv"
@ -38,6 +39,8 @@ func StartSecureServer() {
globals.Logger.Errorf("Secure: %v", err)
})
globals.MatchmakingManager = common_globals.NewMatchmakingManager(globals.SecureEndpoint, globals.Postgres)
registerCommonSecureServerProtocols()
port, _ := strconv.Atoi(os.Getenv("PN_MINECRAFT_SECURE_SERVER_PORT"))