stubbed GetCourseRecord

This commit is contained in:
Jonathan Barrow
2021-09-28 19:14:23 -04:00
parent ed3de908e8
commit 7961ea89d8
2 changed files with 54 additions and 0 deletions

53
get_course_record.go Normal file
View File

@@ -0,0 +1,53 @@
package main
import (
nex "github.com/PretendoNetwork/nex-go"
nexproto "github.com/PretendoNetwork/nex-protocols-go"
)
func getCourseRecord(err error, client *nex.Client, callID uint32, param *nexproto.DataStoreGetCourseRecordParam) {
// TODO complete this
// Hard coded to always say the course creator holds the world record
/*
courseMetadata := getCourseMetadataByDataID(param.DataID)
result := nexproto.NewDataStoreGetCourseRecordResult()
result.DataID = param.DataID
result.Slot = 0
result.FirstPID = courseMetadata.OwnerPID
result.BestPID = courseMetadata.OwnerPID
result.BestScore = 0
result.CreatedTime = nex.NewDateTime(0)
result.UpdatedTime = nex.NewDateTime(0)
rmcResponseStream := nex.NewStreamOut(nexServer)
rmcResponseStream.WriteStructure(result)
rmcResponseBody := rmcResponseStream.Bytes()
rmcResponse := nex.NewRMCResponse(nexproto.DataStoreSMMProtocolID, callID)
rmcResponse.SetSuccess(nexproto.DataStoreSMMMethodGetCourseRecord, rmcResponseBody)
rmcResponseBytes := rmcResponse.Bytes()
*/
rmcResponse := nex.NewRMCResponse(nexproto.DataStoreSMMProtocolID, callID)
rmcResponse.SetError(0x00690004)
rmcResponseBytes := rmcResponse.Bytes()
responsePacket, _ := nex.NewPacketV1(client, nil)
responsePacket.SetVersion(1)
responsePacket.SetSource(0xA1)
responsePacket.SetDestination(0xAF)
responsePacket.SetType(nex.DataPacket)
responsePacket.SetPayload(rmcResponseBytes)
responsePacket.AddFlag(nex.FlagNeedsAck)
responsePacket.AddFlag(nex.FlagReliable)
nexServer.Send(responsePacket)
}

View File

@@ -75,6 +75,7 @@ func main() {
dataStoreSmmServer.GetApplicationConfig(getApplicationConfig)
dataStoreSmmServer.FollowingsLatestCourseSearchObject(followingsLatestCourseSearchObject)
dataStoreSmmServer.RecommendedCourseSearchObject(recommendedCourseSearchObject)
dataStoreSmmServer.GetCourseRecord(getCourseRecord)
dataStoreSmmServer.GetApplicationConfigString(getApplicationConfigString)
dataStoreSmmServer.GetMetasWithCourseRecord(getMetasWithCourseRecord)
dataStoreSmmServer.CTRPickUpCourseSearchObject(ctrPickUpCourseSearchObject)