Skip to content

Commit

Permalink
Added MatchmakeExtension::UpdateProgressScore
Browse files Browse the repository at this point in the history
  • Loading branch information
jonbarrow committed Apr 8, 2023
1 parent 3ff1811 commit e36462c
Show file tree
Hide file tree
Showing 2 changed files with 47 additions and 0 deletions.
15 changes: 15 additions & 0 deletions matchmake-extension/protocol.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,18 @@ const (

// MethodGetSimplePlayingSession is the method ID for method GetSimplePlayingSession
MethodGetSimplePlayingSession = 0x1F

// MethodUpdateProgressScore is the method ID for method UpdateProgressScore
MethodUpdateProgressScore = 0x22

// MethodCreateMatchmakeSessionWithParam is the method ID for method CreateMatchmakeSessionWithParam
MethodCreateMatchmakeSessionWithParam = 0x26

// MethodJoinMatchmakeSessionWithParam is the method ID for method JoinMatchmakeSessionWithParam
MethodJoinMatchmakeSessionWithParam = 0x27

// MethodAutoMatchmakeWithParam_Postpone is the method ID for method AutoMatchmakeWithParam_Postpone
MethodAutoMatchmakeWithParam_Postpone = 0x28
)

// MatchmakeExtensionProtocol handles the Matchmake Extension nex protocol
Expand All @@ -56,6 +68,7 @@ type MatchmakeExtensionProtocol struct {
GetPlayingSessionHandler func(err error, client *nex.Client, callID uint32, lstPID []uint32)
JoinMatchmakeSessionExHandler func(err error, client *nex.Client, callID uint32, gid uint32, strMessage string, dontCareMyBlockList bool, participationCount uint16)
GetSimplePlayingSessionHandler func(err error, client *nex.Client, callID uint32, listPID []uint32, includeLoginUser bool)
UpdateProgressScoreHandler func(err error, client *nex.Client, callID uint32, GID uint32, progressScore uint8)
}

// Setup initializes the protocol
Expand Down Expand Up @@ -93,6 +106,8 @@ func (protocol *MatchmakeExtensionProtocol) HandlePacket(packet nex.PacketInterf
go protocol.HandleJoinMatchmakeSessionEx(packet)
case MethodGetSimplePlayingSession:
go protocol.HandleGetSimplePlayingSession(packet)
case MethodUpdateProgressScore:
go protocol.HandleUpdateProgressScore(packet)
default:
go globals.RespondNotImplemented(packet, ProtocolID)
fmt.Printf("Unsupported Matchmake Extension method ID: %#v\n", request.MethodID())
Expand Down
32 changes: 32 additions & 0 deletions matchmake-extension/update_progress_score.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
package matchmake_extension

import (
nex "github.com/PretendoNetwork/nex-go"
"github.com/PretendoNetwork/nex-protocols-go/globals"
)

// UpdateProgressScore sets the UpdateProgressScore handler function
func (protocol *MatchmakeExtensionProtocol) UpdateProgressScore(handler func(err error, client *nex.Client, callID uint32, GID uint32, progressScore uint8)) {
protocol.UpdateProgressScoreHandler = handler
}

func (protocol *MatchmakeExtensionProtocol) HandleUpdateProgressScore(packet nex.PacketInterface) {
if protocol.UpdateProgressScoreHandler == nil {
globals.Logger.Warning("MatchmakeExtension::UpdateProgressScore not implemented")
go globals.RespondNotImplemented(packet, ProtocolID)
return
}

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

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

parametersStream := nex.NewStreamIn(parameters, protocol.Server)

GID := parametersStream.ReadUInt32LE()
progressScore := parametersStream.ReadUInt8()

go protocol.UpdateProgressScoreHandler(nil, client, callID, GID, progressScore)
}

0 comments on commit e36462c

Please sign in to comment.