From 7961ea89d8d940a561b7530d952b5075ea258faa Mon Sep 17 00:00:00 2001 From: Jonathan Barrow Date: Tue, 28 Sep 2021 19:14:23 -0400 Subject: [PATCH] stubbed GetCourseRecord --- get_course_record.go | 53 ++++++++++++++++++++++++++++++++++++++++++++ main.go | 1 + 2 files changed, 54 insertions(+) create mode 100644 get_course_record.go diff --git a/get_course_record.go b/get_course_record.go new file mode 100644 index 0000000..dde3557 --- /dev/null +++ b/get_course_record.go @@ -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) +} diff --git a/main.go b/main.go index 13574ed..2f7e7e8 100644 --- a/main.go +++ b/main.go @@ -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)