Skip to content

Commit

Permalink
Added MatchMaking.FindBySingleID
Browse files Browse the repository at this point in the history
  • Loading branch information
jonbarrow committed Sep 3, 2022
1 parent a137f1d commit 4f83af7
Showing 1 changed file with 31 additions and 0 deletions.
31 changes: 31 additions & 0 deletions matchmaking.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,9 @@ const (
// MatchMakingMethodUnregisterGatherings is the method ID for the method UnregisterGatherings
MatchMakingMethodUnregisterGatherings = 0x3

// MatchMakingMethodFindBySingleID is the method ID for the method FindBySingleID
MatchMakingMethodFindBySingleID = 0x15

// MatchMakingMethodGetSessionURLs is the method ID for the method GetSessionURLs
MatchMakingMethodGetSessionURLs = 0x29
)
Expand All @@ -25,6 +28,7 @@ type MatchMakingProtocol struct {
server *nex.Server
UnregisterGatheringHandler func(err error, client *nex.Client, callID uint32, idGathering uint32)
UnregisterGatheringsHandler func(err error, client *nex.Client, callID uint32, lstGatherings []uint32)
FindBySingleIDHandler func(err error, client *nex.Client, callID uint32, id uint32)
GetSessionURLsHandler func(err error, client *nex.Client, callID uint32, gatheringId uint32)
}

Expand All @@ -41,6 +45,8 @@ func (matchMakingProtocol *MatchMakingProtocol) Setup() {
go matchMakingProtocol.handleMatchMakingMethodUnregisterGathering(packet)
case MatchMakingMethodUnregisterGatherings:
go matchMakingProtocol.handleMatchMakingMethodUnregisterGatherings(packet)
case MatchMakingMethodFindBySingleID:
go matchMakingProtocol.handleFindBySingleID(packet)
case MatchMakingMethodGetSessionURLs:
go matchMakingProtocol.handleGetSessionURLs(packet)
default:
Expand All @@ -61,6 +67,11 @@ func (matchMakingProtocol *MatchMakingProtocol) UnregisterGatherings(handler fun
matchMakingProtocol.UnregisterGatheringsHandler = handler
}

// FindBySingleID sets the FindBySingleID handler function
func (matchMakingProtocol *MatchMakingProtocol) FindBySingleID(handler func(err error, client *nex.Client, callID uint32, id uint32)) {
matchMakingProtocol.FindBySingleIDHandler = handler
}

// GetSessionURLs sets the GetSessionURLs handler function
func (matchMakingProtocol *MatchMakingProtocol) GetSessionURLs(handler func(err error, client *nex.Client, callID uint32, gatheringId uint32)) {
matchMakingProtocol.GetSessionURLsHandler = handler
Expand Down Expand Up @@ -106,6 +117,26 @@ func (matchMakingProtocol *MatchMakingProtocol) handleMatchMakingMethodUnregiste
go matchMakingProtocol.UnregisterGatheringsHandler(nil, client, callID, lstGatherings)
}

func (matchMakingProtocol *MatchMakingProtocol) handleFindBySingleID(packet nex.PacketInterface) {
if matchMakingProtocol.FindBySingleIDHandler == nil {
logger.Warning("MatchMakingProtocol::FindBySingleID not implemented")
go respondNotImplemented(packet, MatchMakingProtocolID)
return
}

client := packet.Sender()
request := packet.RMCRequest()

callID := request.CallID()
parameters := request.Parameters()

parametersStream := nex.NewStreamIn(parameters, matchMakingProtocol.server)

id := parametersStream.ReadUInt32LE()

go matchMakingProtocol.FindBySingleIDHandler(nil, client, callID, id)
}

func (matchMakingProtocol *MatchMakingProtocol) handleGetSessionURLs(packet nex.PacketInterface) {
if matchMakingProtocol.GetSessionURLsHandler == nil {
logger.Warning("MatchMakingProtocol::GetSessionURLs not implemented")
Expand Down

0 comments on commit 4f83af7

Please sign in to comment.