AddToBufferQueues death data

This commit is contained in:
Jonathan Barrow 2021-09-29 20:40:07 -04:00
parent f6ba328f48
commit 91c2e53115
5 changed files with 101 additions and 6 deletions

43
add_to_buffer_queues.go Normal file
View File

@ -0,0 +1,43 @@
package main
import (
nex "github.com/PretendoNetwork/nex-go"
nexproto "github.com/PretendoNetwork/nex-protocols-go"
)
func addToBufferQueues(err error, client *nex.Client, callID uint32, params []*nexproto.BufferQueueParam, buffers [][]byte) {
pResults := make([]uint32, 0)
for i := 0; i < len(params); i++ {
buffer := buffers[i]
param := params[i]
insertBufferQueueData(param.DataID, param.Slot, buffer)
pResults = append(pResults, 0x690001)
}
rmcResponseStream := nex.NewStreamOut(nexServer)
rmcResponseStream.WriteListUInt32LE(pResults)
rmcResponseBody := rmcResponseStream.Bytes()
rmcResponse := nex.NewRMCResponse(nexproto.DataStoreProtocolID, callID)
rmcResponse.SetSuccess(nexproto.DataStoreSMMMethodAddToBufferQueues, rmcResponseBody)
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,8 +75,8 @@ func connectCassandra() {
}
if err := cassandraClusterSession.Query(`CREATE TABLE IF NOT EXISTS pretendo_smm.buffer_queues (
id int PRIMARY KEY,
data_id int,
id uuid PRIMARY KEY,
data_id bigint,
slot int,
buffer blob
)`).Exec(); err != nil {
@ -284,6 +284,12 @@ func getCourseMetadataByDataIDs(dataIDs []uint64) []*CourseMetadata {
return courseMetadatas
}
func insertBufferQueueData(dataID uint64, slot uint32, buffer []byte) {
if err := cassandraClusterSession.Query(`INSERT INTO pretendo_smm.buffer_queues( id, data_id, slot, buffer ) VALUES ( now(), ?, ?, ? ) IF NOT EXISTS`, dataID, slot, buffer).Exec(); err != nil {
log.Fatal(err)
}
}
//////////////////////////////
// //
// MongoDB database methods //

View File

@ -69,6 +69,7 @@ func main() {
dataStoreSmmServer.GetObjectInfos(getObjectInfos)
dataStoreSmmServer.RateCustomRanking(rateCustomRanking)
dataStoreSmmServer.GetCustomRankingByDataId(getCustomRankingByDataId)
dataStoreSmmServer.AddToBufferQueues(addToBufferQueues)
dataStoreSmmServer.GetBufferQueue(getBufferQueue)
dataStoreSmmServer.CompleteAttachFile(completeAttachFile)
dataStoreSmmServer.PrepareAttachFile(prepareAttachFile)

View File

@ -44,16 +44,58 @@ func recommendedCourseSearchObject(err error, client *nex.Client, callID uint32,
rankingResult.MetaInfo.Flag = courseMetadata.Flag
rankingResult.MetaInfo.ReferredTime = nex.NewDateTime(now)
rankingResult.MetaInfo.ExpireTime = nex.NewDateTime(now)
rankingResult.MetaInfo.Tags = []string{""} // idk?
rankingResult.MetaInfo.Tags = []string{"AYMHAAADAAB2V0gFWV1WtQ"} // idk?
rankingResult.MetaInfo.Ratings = []*nexproto.DataStoreRatingInfoWithSlot{
nexproto.NewDataStoreRatingInfoWithSlot(),
nexproto.NewDataStoreRatingInfoWithSlot(),
nexproto.NewDataStoreRatingInfoWithSlot(),
nexproto.NewDataStoreRatingInfoWithSlot(),
nexproto.NewDataStoreRatingInfoWithSlot(),
nexproto.NewDataStoreRatingInfoWithSlot(),
nexproto.NewDataStoreRatingInfoWithSlot(),
}
rankingResult.MetaInfo.Ratings[0].Slot = 0
rankingResult.MetaInfo.Ratings[0].Rating = nexproto.NewDataStoreRatingInfo()
rankingResult.MetaInfo.Ratings[0].Rating.TotalValue = 3
rankingResult.MetaInfo.Ratings[0].Rating.Count = 3
rankingResult.MetaInfo.Ratings[0].Rating.TotalValue = 0
rankingResult.MetaInfo.Ratings[0].Rating.Count = 0
rankingResult.MetaInfo.Ratings[0].Rating.InitialValue = 0
rankingResult.MetaInfo.Ratings[1].Slot = 1
rankingResult.MetaInfo.Ratings[1].Rating = nexproto.NewDataStoreRatingInfo()
rankingResult.MetaInfo.Ratings[1].Rating.TotalValue = 0
rankingResult.MetaInfo.Ratings[1].Rating.Count = 0
rankingResult.MetaInfo.Ratings[1].Rating.InitialValue = 0
rankingResult.MetaInfo.Ratings[2].Slot = 2
rankingResult.MetaInfo.Ratings[2].Rating = nexproto.NewDataStoreRatingInfo()
rankingResult.MetaInfo.Ratings[2].Rating.TotalValue = 0
rankingResult.MetaInfo.Ratings[2].Rating.Count = 0
rankingResult.MetaInfo.Ratings[2].Rating.InitialValue = 0
rankingResult.MetaInfo.Ratings[3].Slot = 3
rankingResult.MetaInfo.Ratings[3].Rating = nexproto.NewDataStoreRatingInfo()
rankingResult.MetaInfo.Ratings[3].Rating.TotalValue = 0
rankingResult.MetaInfo.Ratings[3].Rating.Count = 0
rankingResult.MetaInfo.Ratings[3].Rating.InitialValue = 0
rankingResult.MetaInfo.Ratings[4].Slot = 4
rankingResult.MetaInfo.Ratings[4].Rating = nexproto.NewDataStoreRatingInfo()
rankingResult.MetaInfo.Ratings[4].Rating.TotalValue = 0
rankingResult.MetaInfo.Ratings[4].Rating.Count = 0
rankingResult.MetaInfo.Ratings[4].Rating.InitialValue = 0
rankingResult.MetaInfo.Ratings[5].Slot = 5
rankingResult.MetaInfo.Ratings[5].Rating = nexproto.NewDataStoreRatingInfo()
rankingResult.MetaInfo.Ratings[5].Rating.TotalValue = 0
rankingResult.MetaInfo.Ratings[5].Rating.Count = 0
rankingResult.MetaInfo.Ratings[5].Rating.InitialValue = 0
rankingResult.MetaInfo.Ratings[6].Slot = 6
rankingResult.MetaInfo.Ratings[6].Rating = nexproto.NewDataStoreRatingInfo()
rankingResult.MetaInfo.Ratings[6].Rating.TotalValue = 0
rankingResult.MetaInfo.Ratings[6].Rating.Count = 0
rankingResult.MetaInfo.Ratings[6].Rating.InitialValue = 0
pRankingResults = append(pRankingResults, rankingResult)
}

View File

@ -1,6 +1,7 @@
package main
import (
"fmt"
"time"
nex "github.com/PretendoNetwork/nex-go"
@ -12,7 +13,9 @@ func suggestedCourseSearchObject(err error, client *nex.Client, callID uint32, p
pRankingResults := make([]*nexproto.DataStoreCustomRankingResult, 0)
courseMetadatas := getCourseMetadatasByLimit(100) // In PCAPs param.minimalRatingFrequency is 100 but is 0 here?
fmt.Println(param.MinimalRatingFrequency)
courseMetadatas := getCourseMetadatasByLimit(4) // In PCAPs param.minimalRatingFrequency is 4 but is 0 here?
for i := 0; i < len(courseMetadatas); i++ {
now := uint64(time.Now().Unix())