mirror of
https://github.com/PretendoNetwork/splatoon.git
synced 2026-09-11 21:05:15 -05:00
feat: matchmaking rewrite implementation
This commit is contained in:
@@ -1,7 +1,9 @@
|
||||
package globals
|
||||
|
||||
import (
|
||||
"database/sql"
|
||||
pb "github.com/PretendoNetwork/grpc-go/account"
|
||||
"github.com/PretendoNetwork/nex-protocols-common-go/v2/globals"
|
||||
"github.com/PretendoNetwork/nex-go/v2"
|
||||
"github.com/PretendoNetwork/plogger-go"
|
||||
"google.golang.org/grpc"
|
||||
@@ -20,3 +22,6 @@ var SecureEndpoint *nex.PRUDPEndPoint
|
||||
var GRPCAccountClientConnection *grpc.ClientConn
|
||||
var GRPCAccountClient pb.AccountClient
|
||||
var GRPCAccountCommonMetadata metadata.MD
|
||||
|
||||
var Postgres *sql.DB
|
||||
var MatchmakingManager *common_globals.MatchmakingManager
|
||||
|
||||
10
go.mod
10
go.mod
@@ -1,8 +1,6 @@
|
||||
module github.com/PretendoNetwork/splatoon
|
||||
|
||||
go 1.21
|
||||
|
||||
toolchain go1.21.9
|
||||
go 1.22.1
|
||||
|
||||
require (
|
||||
github.com/PretendoNetwork/grpc-go v1.0.2
|
||||
@@ -15,11 +13,13 @@ require (
|
||||
)
|
||||
|
||||
require (
|
||||
github.com/PretendoNetwork/pq-extended v1.0.0 // indirect
|
||||
github.com/dolthub/maphash v0.1.0 // indirect
|
||||
github.com/fatih/color v1.17.0 // indirect
|
||||
github.com/golang/protobuf v1.5.4 // indirect
|
||||
github.com/jwalton/go-supportscolor v1.2.0 // indirect
|
||||
github.com/klauspost/compress v1.17.9 // indirect
|
||||
github.com/lib/pq v1.10.9 // indirect
|
||||
github.com/lxzan/gws v1.8.5 // indirect
|
||||
github.com/mattn/go-colorable v0.1.13 // indirect
|
||||
github.com/mattn/go-isatty v0.0.20 // indirect
|
||||
@@ -34,3 +34,7 @@ require (
|
||||
google.golang.org/genproto/googleapis/rpc v0.0.0-20240617180043-68d350f18fd4 // indirect
|
||||
google.golang.org/protobuf v1.34.2 // indirect
|
||||
)
|
||||
|
||||
replace github.com/PretendoNetwork/nex-protocols-common-go/v2 => /root/nex-protocols-common-go
|
||||
|
||||
replace github.com/PretendoNetwork/nex-protocols-go/v2 => /root/nex-protocols-go
|
||||
|
||||
8
go.sum
8
go.sum
@@ -2,12 +2,10 @@ github.com/PretendoNetwork/grpc-go v1.0.2 h1:9TvKmX7dCOANyoHEra1MMYqS1N/RGav66TR
|
||||
github.com/PretendoNetwork/grpc-go v1.0.2/go.mod h1:XZjEsij9lL7HJBNkH6JPbBIkUSq/1rjflvjGdv+DAj0=
|
||||
github.com/PretendoNetwork/nex-go/v2 v2.0.2 h1:mPp27Ero3Rr28nekuKg4f0tdp28NzmCJXgupt2paT18=
|
||||
github.com/PretendoNetwork/nex-go/v2 v2.0.2/go.mod h1:O5v200Ro8bdrmqSAmzV0cqQsG7cdmwLHAet5X7Jxz20=
|
||||
github.com/PretendoNetwork/nex-protocols-common-go/v2 v2.0.5 h1:17b7vA8wjWLW9JdJTHeOoX2g2e4S/EwA32m9AuPEA80=
|
||||
github.com/PretendoNetwork/nex-protocols-common-go/v2 v2.0.5/go.mod h1:0wDEYxDYbUOjsKjsTUjU0/f3pL1MT54h+tGn4UyeB+A=
|
||||
github.com/PretendoNetwork/nex-protocols-go/v2 v2.0.3 h1:80CG7f9w/34MN1vAZ1XP3ec4LJ4mqKlkests+HQzrvc=
|
||||
github.com/PretendoNetwork/nex-protocols-go/v2 v2.0.3/go.mod h1:2UN8khoMDNaeJ4GcIG7ez7MqqmbLfLzbVS6hSa+kGnk=
|
||||
github.com/PretendoNetwork/plogger-go v1.0.4 h1:PF7xHw9eDRHH+RsAP9tmAE7fG0N0p6H4iPwHKnsoXwc=
|
||||
github.com/PretendoNetwork/plogger-go v1.0.4/go.mod h1:7kD6M4vPq1JL4LTuPg6kuB1OvUBOwQOtAvTaUwMbwvU=
|
||||
github.com/PretendoNetwork/pq-extended v1.0.0 h1:GHZ0hLvCvmYKQPTV9I9XtTx8J1iB5Z9CEnfW2tUpsYg=
|
||||
github.com/PretendoNetwork/pq-extended v1.0.0/go.mod h1:bq6Ai+3lG4/M0iamUBt2Uzi5vL/nYy1a1Ar2ow9NDF0=
|
||||
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
|
||||
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
|
||||
github.com/dolthub/maphash v0.1.0 h1:bsQ7JsF4FkkWyrP3oCnFJgrCUAFbFf3kOl4L/QxPDyQ=
|
||||
@@ -24,6 +22,8 @@ github.com/jwalton/go-supportscolor v1.2.0 h1:g6Ha4u7Vm3LIsQ5wmeBpS4gazu0UP1DRDE
|
||||
github.com/jwalton/go-supportscolor v1.2.0/go.mod h1:hFVUAZV2cWg+WFFC4v8pT2X/S2qUUBYMioBD9AINXGs=
|
||||
github.com/klauspost/compress v1.17.9 h1:6KIumPrER1LHsvBVuDa0r5xaG0Es51mhhB9BQB2qeMA=
|
||||
github.com/klauspost/compress v1.17.9/go.mod h1:Di0epgTjJY877eYKx5yC51cX2A2Vl2ibi7bDH9ttBbw=
|
||||
github.com/lib/pq v1.10.9 h1:YXG7RB+JIjhP29X+OtkiDnYaXQwpS4JEWq7dtCCRUEw=
|
||||
github.com/lib/pq v1.10.9/go.mod h1:AlVN5x4E4T544tWzH6hKfbfQvm3HdbOxrmggDNAPY9o=
|
||||
github.com/lxzan/gws v1.8.5 h1:6x+wW3EHtoGFNeCtZP1OVZ1IHrpZZzDaEjQGg1lUJqU=
|
||||
github.com/lxzan/gws v1.8.5/go.mod h1:FcGeRMB7HwGuTvMLR24ku0Zx0p6RXqeKASeMc4VYgi4=
|
||||
github.com/mattn/go-colorable v0.1.13 h1:fFA4WZxdEF4tXPZVKMLwD8oUnCTTo08duU7wxecdEvA=
|
||||
|
||||
6
init.go
6
init.go
@@ -1,6 +1,7 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"database/sql"
|
||||
"fmt"
|
||||
"os"
|
||||
"strconv"
|
||||
@@ -104,4 +105,9 @@ func init() {
|
||||
globals.GRPCAccountCommonMetadata = metadata.Pairs(
|
||||
"X-API-Key", accountGRPCAPIKey,
|
||||
)
|
||||
globals.Postgres, err = sql.Open("postgres", os.Getenv("PN_SPLATOON_POSTGRES_URI"))
|
||||
if err != nil {
|
||||
globals.Logger.Critical(err.Error())
|
||||
}
|
||||
globals.Logger.Success("Connected to Postgres!")
|
||||
}
|
||||
|
||||
@@ -3,7 +3,7 @@ package nex
|
||||
import (
|
||||
"github.com/PretendoNetwork/nex-go/v2"
|
||||
"github.com/PretendoNetwork/nex-go/v2/types"
|
||||
common_globals "github.com/PretendoNetwork/nex-protocols-common-go/v2/globals"
|
||||
// commonglobals "github.com/PretendoNetwork/nex-protocols-common-go/v2/globals"
|
||||
commonnattraversal "github.com/PretendoNetwork/nex-protocols-common-go/v2/nat-traversal"
|
||||
commonsecure "github.com/PretendoNetwork/nex-protocols-common-go/v2/secure-connection"
|
||||
nattraversal "github.com/PretendoNetwork/nex-protocols-go/v2/nat-traversal"
|
||||
@@ -112,11 +112,11 @@ func gameSpecificMatchmakeSessionSearchCriteriaChecksHandler(searchCriteria *mat
|
||||
func onAfterAutoMatchmakeWithParamPostpone(_ nex.PacketInterface, _ *matchmakingtypes.AutoMatchmakeParam) {
|
||||
// * This is ugly but I can't work out a better way to do this
|
||||
// * Set Splatfest rooms to open participation
|
||||
for _, session := range common_globals.Sessions {
|
||||
if session.GameMatchmakeSession != nil && session.GameMatchmakeSession.GameMode.Value == 12 {
|
||||
session.GameMatchmakeSession.OpenParticipation.Value = true
|
||||
}
|
||||
}
|
||||
// for _, session := range common_globals.Sessions {
|
||||
// if session.GameMatchmakeSession != nil && session.GameMatchmakeSession.GameMode.Value == 12 {
|
||||
// session.GameMatchmakeSession.OpenParticipation.Value = true
|
||||
// }
|
||||
// }
|
||||
}
|
||||
|
||||
func registerCommonSecureServerProtocols() {
|
||||
@@ -132,18 +132,23 @@ func registerCommonSecureServerProtocols() {
|
||||
|
||||
matchMakingProtocol := matchmaking.NewProtocol()
|
||||
globals.SecureEndpoint.RegisterServiceProtocol(matchMakingProtocol)
|
||||
commonmatchmaking.NewCommonProtocol(matchMakingProtocol)
|
||||
//commonmatchmaking.NewCommonProtocol(matchMakingProtocol)
|
||||
commonMatchMakingProtocol := commonmatchmaking.NewCommonProtocol(matchMakingProtocol)
|
||||
commonMatchMakingProtocol.SetManager(globals.MatchmakingManager)
|
||||
|
||||
matchMakingExtProtocol := matchmakingext.NewProtocol()
|
||||
globals.SecureEndpoint.RegisterServiceProtocol(matchMakingExtProtocol)
|
||||
commonmatchmakingext.NewCommonProtocol(matchMakingExtProtocol)
|
||||
// commonmatchmakingext.NewCommonProtocol(matchMakingExtProtocol)
|
||||
commonMatchMakingExtProtocol := commonmatchmakingext.NewCommonProtocol(matchMakingExtProtocol)
|
||||
commonMatchMakingExtProtocol.SetManager(globals.MatchmakingManager)
|
||||
|
||||
matchmakeExtensionProtocol := matchmakeextension.NewProtocol()
|
||||
globals.SecureEndpoint.RegisterServiceProtocol(matchmakeExtensionProtocol)
|
||||
commonMatchmakeExtensionProtocol := commonmatchmakeextension.NewCommonProtocol(matchmakeExtensionProtocol)
|
||||
matchmakeExtensionProtocol.SetHandlerGetPlayingSession(stubGetPlayingSession)
|
||||
commonMatchmakeExtensionProtocol.GameSpecificMatchmakeSessionSearchCriteriaChecks = gameSpecificMatchmakeSessionSearchCriteriaChecksHandler
|
||||
// commonMatchmakeExtensionProtocol.CleanupMatchmakeSessionSearchCriteriaChecks = gameSpecificMatchmakeSessionSearchCriteriaChecksHandler
|
||||
commonMatchmakeExtensionProtocol.OnAfterAutoMatchmakeWithParamPostpone = onAfterAutoMatchmakeWithParamPostpone
|
||||
commonMatchmakeExtensionProtocol.SetManager(globals.MatchmakingManager)
|
||||
|
||||
rankingProtocol := ranking.NewProtocol(globals.SecureEndpoint)
|
||||
globals.SecureEndpoint.RegisterServiceProtocol(rankingProtocol)
|
||||
|
||||
@@ -2,6 +2,7 @@ package nex
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
common_globals "github.com/PretendoNetwork/nex-protocols-common-go/v2/globals"
|
||||
"os"
|
||||
"strconv"
|
||||
|
||||
@@ -36,6 +37,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_SPLATOON_SECURE_SERVER_PORT"))
|
||||
|
||||
Reference in New Issue
Block a user