mirror of
https://github.com/PretendoNetwork/friends.git
synced 2024-06-01 11:37:53 -04:00
2f80336681
Replace MongoDB usage with GRPC calls to the account server. Also include documentation on the README and a Makefile.
46 lines
1.4 KiB
Go
46 lines
1.4 KiB
Go
package nex_friends_3ds
|
|
|
|
import (
|
|
database_3ds "github.com/PretendoNetwork/friends/database/3ds"
|
|
"github.com/PretendoNetwork/friends/globals"
|
|
notifications_3ds "github.com/PretendoNetwork/friends/notifications/3ds"
|
|
nex "github.com/PretendoNetwork/nex-go"
|
|
friends_3ds "github.com/PretendoNetwork/nex-protocols-go/friends-3ds"
|
|
friends_3ds_types "github.com/PretendoNetwork/nex-protocols-go/friends-3ds/types"
|
|
)
|
|
|
|
func UpdateFavoriteGameKey(err error, client *nex.Client, callID uint32, gameKey *friends_3ds_types.GameKey) uint32 {
|
|
if err != nil {
|
|
globals.Logger.Error(err.Error())
|
|
return nex.Errors.FPD.InvalidArgument
|
|
}
|
|
|
|
err = database_3ds.UpdateUserFavoriteGame(client.PID(), gameKey)
|
|
if err != nil {
|
|
globals.Logger.Critical(err.Error())
|
|
return nex.Errors.FPD.Unknown
|
|
}
|
|
|
|
go notifications_3ds.SendFavoriteUpdate(client, gameKey)
|
|
|
|
rmcResponse := nex.NewRMCResponse(friends_3ds.ProtocolID, callID)
|
|
rmcResponse.SetSuccess(friends_3ds.MethodUpdateFavoriteGameKey, nil)
|
|
|
|
rmcResponseBytes := rmcResponse.Bytes()
|
|
|
|
responsePacket, _ := nex.NewPacketV0(client, nil)
|
|
|
|
responsePacket.SetVersion(0)
|
|
responsePacket.SetSource(0xA1)
|
|
responsePacket.SetDestination(0xAF)
|
|
responsePacket.SetType(nex.DataPacket)
|
|
responsePacket.SetPayload(rmcResponseBytes)
|
|
|
|
responsePacket.AddFlag(nex.FlagNeedsAck)
|
|
responsePacket.AddFlag(nex.FlagReliable)
|
|
|
|
globals.SecureServer.Send(responsePacket)
|
|
|
|
return 0
|
|
}
|