feat(matchmaking): replace legacy rpc_find_match with Nakama native matchmaking
### Summary This update removes the old RPC-driven matchmaking flow and replaces it with proper Nakama matchmaker integration. Players now queue using `matchmaker_add` over WebSockets, and matches are created via `MatchmakerMatched` callback. ### Changes - Removed `rpc_find_match` and MatchList polling logic - Added `MatchmakerMatched` handler to auto-create TicTacToe matches - Added RPC stubs `join_matchmaking` & `leave_matchmaking` only for optional validation (no server-side queueing) - Updated `main.go` to register: ✅ `tictactoe` authoritative match ✅ `matchmaker_matched` callback ✅ removed obsolete rpc_find_match registration - Ensured module loads successfully with cleaner InitModule - Cleaned unused imports and outdated Nakama calls ### Benefits - Fully scalable & production-ready matchmaking flow - Eliminates race conditions & manual match assignment - Supports multiple queues (classic / blitz) via string properties - Aligns plugin with Nakama best practices - Enables Python/WebSocket simulation without RPC dependencies
This commit is contained in:
@@ -7,12 +7,13 @@ import (
|
||||
"github.com/heroiclabs/nakama-common/runtime"
|
||||
)
|
||||
|
||||
// Example RPC
|
||||
func HelloWorld(
|
||||
ctx context.Context,
|
||||
logger runtime.Logger,
|
||||
db *sql.DB,
|
||||
nk runtime.NakamaModule,
|
||||
payload string,
|
||||
ctx context.Context,
|
||||
logger runtime.Logger,
|
||||
db *sql.DB,
|
||||
nk runtime.NakamaModule,
|
||||
payload string,
|
||||
) (string, error) {
|
||||
logger.Info("HelloWorld RPC called — payload: %s", payload)
|
||||
return `{"message": "Hello from Go RPC!"}`, nil
|
||||
@@ -34,8 +35,13 @@ func InitModule(
|
||||
logger.Error("Failed to register RPC: %v", err)
|
||||
return err
|
||||
}
|
||||
if err := initializer.RegisterRpc("rpc_find_match", rpcFindMatch); err != nil {
|
||||
logger.Error("RegisterRpc rpc_find_match failed: %v", err)
|
||||
// Match making
|
||||
if err := initializer.RegisterRpc("leave_matchmaking", rpcLeaveMatchmaking); err != nil {
|
||||
logger.Error("RegisterRpc leave_matchmaking failed: %v", err)
|
||||
return err
|
||||
}
|
||||
if err := initializer.RegisterMatchmakerMatched(MatchmakerMatched); err != nil {
|
||||
logger.Error("RegisterMatchmakerMatched failed: %v", err)
|
||||
return err
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user