wiiu-chat-secure/nex/matchmake-extension/create_matchmake_session.go
2025-02-21 09:56:13 -08:00

30 lines
1.2 KiB
Go

package nex_matchmake_extension
import (
//"math/rand"
nex "github.com/PretendoNetwork/nex-go/v2"
"github.com/PretendoNetwork/nex-go/v2/types"
"github.com/PretendoNetwork/wiiu-chat/globals"
match_making_types "github.com/PretendoNetwork/nex-protocols-go/v2/match-making/types"
matchmake_extension "github.com/PretendoNetwork/nex-protocols-go/v2/matchmake-extension"
)
func CreateMatchmakeSession(err error, packet nex.PacketInterface, callID uint32, anyGathering match_making_types.GatheringHolder, message types.String, participationCount types.UInt16) (*nex.RMCMessage, *nex.Error) {
var gid types.UInt32 = types.NewUInt32(uint32(packet.Sender().PID())) // TODO: Randomize this
sessionKey := make([]byte, 32)
sessionKeyBuffer := types.NewBuffer(sessionKey)
rmcResponseStream := nex.NewByteStreamOut(globals.SecureServer.LibraryVersions, globals.SecureServer.ByteStreamSettings)
gid.WriteTo(rmcResponseStream)
sessionKeyBuffer.WriteTo(rmcResponseStream)
rmcResponse := nex.NewRMCSuccess(globals.SecureEndpoint, rmcResponseStream.Bytes())
rmcResponse.ProtocolID = matchmake_extension.ProtocolID
rmcResponse.CallID = callID
rmcResponse.MethodID = matchmake_extension.MethodCreateMatchmakeSession
return rmcResponse, nil
}