Skip to content

Commit 75d247c

Browse files
committed
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.
1 parent 8a30e47 commit 75d247c

File tree

4 files changed

+22
-2
lines changed

4 files changed

+22
-2
lines changed

globals/globals.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,10 @@
11
package globals
22

33
import (
4+
"database/sql"
45
pb "github.com/PretendoNetwork/grpc-go/account"
56
"github.com/PretendoNetwork/nex-go/v2"
7+
"github.com/PretendoNetwork/nex-protocols-common-go/v2/globals"
68
"github.com/PretendoNetwork/plogger-go"
79
"google.golang.org/grpc"
810
"google.golang.org/grpc/metadata"
@@ -17,6 +19,9 @@ var AuthenticationEndpoint *nex.PRUDPEndPoint
1719
var SecureServer *nex.PRUDPServer
1820
var SecureEndpoint *nex.PRUDPEndPoint
1921

22+
var Postgres *sql.DB
23+
var MatchmakingManager *common_globals.MatchmakingManager
24+
2025
var GRPCAccountClientConnection *grpc.ClientConn
2126
var GRPCAccountClient pb.AccountClient
2227
var GRPCAccountCommonMetadata metadata.MD

init.go

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
package main
22

33
import (
4+
"database/sql"
45
"fmt"
56
"os"
67
"strconv"
@@ -104,4 +105,12 @@ func init() {
104105
globals.GRPCAccountCommonMetadata = metadata.Pairs(
105106
"X-API-Key", accountGRPCAPIKey,
106107
)
108+
109+
globals.Postgres, err = sql.Open("postgres", os.Getenv("PN_MINECRAFT_POSTGRES_URI"))
110+
if err != nil {
111+
globals.Logger.Critical(err.Error())
112+
}
113+
114+
globals.Logger.Success("Connected to Postgres!")
115+
107116
}

nex/register_common_secure_server_protocols.go

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -82,15 +82,18 @@ func registerCommonSecureServerProtocols() {
8282

8383
matchMakingProtocol := matchmaking.NewProtocol()
8484
globals.SecureEndpoint.RegisterServiceProtocol(matchMakingProtocol)
85-
commonmatchmaking.NewCommonProtocol(matchMakingProtocol)
85+
commonMatchMakingProtocol := commonmatchmaking.NewCommonProtocol(matchMakingProtocol)
86+
commonMatchMakingProtocol.SetManager(globals.MatchmakingManager)
8687

8788
matchMakingExtProtocol := matchmakingext.NewProtocol()
8889
globals.SecureEndpoint.RegisterServiceProtocol(matchMakingExtProtocol)
89-
commonmatchmakingext.NewCommonProtocol(matchMakingExtProtocol)
90+
commonMatchMakingExtProtocol := commonmatchmakingext.NewCommonProtocol(matchMakingExtProtocol)
91+
commonMatchMakingExtProtocol.SetManager(globals.MatchmakingManager)
9092

9193
matchmakeExtensionProtocol := matchmakeextension.NewProtocol()
9294
globals.SecureEndpoint.RegisterServiceProtocol(matchmakeExtensionProtocol)
9395
commonMatchmakeExtensionProtocol := commonmatchmakeextension.NewCommonProtocol(matchmakeExtensionProtocol)
96+
commonMatchmakeExtensionProtocol.SetManager(globals.MatchmakingManager)
9497

9598
commonMatchmakeExtensionProtocol.CleanupSearchMatchmakeSession = cleanupSearchMatchmakeSessionHandler
9699
if os.Getenv("PN_MINECRAFT_ALLOW_PUBLIC_MATCHMAKING") != "1" {

nex/secure.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ package nex
22

33
import (
44
"fmt"
5+
common_globals "github.com/PretendoNetwork/nex-protocols-common-go/v2/globals"
56
"os"
67
"strconv"
78

@@ -38,6 +39,8 @@ func StartSecureServer() {
3839
globals.Logger.Errorf("Secure: %v", err)
3940
})
4041

42+
globals.MatchmakingManager = common_globals.NewMatchmakingManager(globals.SecureEndpoint, globals.Postgres)
43+
4144
registerCommonSecureServerProtocols()
4245

4346
port, _ := strconv.Atoi(os.Getenv("PN_MINECRAFT_SECURE_SERVER_PORT"))

0 commit comments

Comments
 (0)