friends/grpc/send_user_notification_wiiu.go
Daniel López Guimaraes 2f80336681
Rename friends-secure to friends and remove Mongo
Replace MongoDB usage with GRPC calls to the account server. Also
include documentation on the README and a Makefile.
2023-08-13 01:05:08 +01:00

42 lines
1.3 KiB
Go

package grpc
import (
"context"
"github.com/PretendoNetwork/friends/globals"
pb "github.com/PretendoNetwork/grpc-go/friends"
nex "github.com/PretendoNetwork/nex-go"
nintendo_notifications "github.com/PretendoNetwork/nex-protocols-go/nintendo-notifications"
empty "github.com/golang/protobuf/ptypes/empty"
)
// SendUserNotificationWiiU implements helloworld.SendUserNotificationWiiU
func (s *gRPCFriendsServer) SendUserNotificationWiiU(ctx context.Context, in *pb.SendUserNotificationWiiURequest) (*empty.Empty, error) {
connectedUser := globals.ConnectedUsers[in.GetPid()]
if connectedUser != nil {
rmcRequest := nex.NewRMCRequest()
rmcRequest.SetProtocolID(nintendo_notifications.ProtocolID)
rmcRequest.SetCallID(3810693103)
rmcRequest.SetMethodID(nintendo_notifications.MethodProcessNintendoNotificationEvent2)
rmcRequest.SetParameters(in.GetNotificationData())
rmcRequestBytes := rmcRequest.Bytes()
requestPacket, _ := nex.NewPacketV0(connectedUser.Client, nil)
requestPacket.SetVersion(0)
requestPacket.SetSource(0xA1)
requestPacket.SetDestination(0xAF)
requestPacket.SetType(nex.DataPacket)
requestPacket.SetPayload(rmcRequestBytes)
requestPacket.AddFlag(nex.FlagNeedsAck)
requestPacket.AddFlag(nex.FlagReliable)
globals.SecureServer.Send(requestPacket)
}
return &empty.Empty{}, nil
}