mirror of
https://github.com/PretendoNetwork/friends.git
synced 2026-03-21 18:04:11 -05:00
Move sending offline notifications to notifications.go and update to PresenceV2
This commit is contained in:
parent
8330f8f139
commit
cb6ff5bf25
|
|
@ -20,7 +20,7 @@ func AcceptFriendRequest(err error, client *nex.Client, callID uint32, id uint64
|
|||
senderFriendInfo := nexproto.NewFriendInfo()
|
||||
|
||||
senderFriendInfo.NNAInfo = senderConnectedUser.NNAInfo
|
||||
senderFriendInfo.Presence = senderConnectedUser.Presence
|
||||
senderFriendInfo.Presence = senderConnectedUser.PresenceV2
|
||||
senderFriendInfo.Status = database_wiiu.GetUserComment(senderPID)
|
||||
senderFriendInfo.BecameFriend = friendInfo.BecameFriend
|
||||
senderFriendInfo.LastOnline = friendInfo.LastOnline // TODO: Change this
|
||||
|
|
|
|||
64
wiiu/notifications.go
Normal file
64
wiiu/notifications.go
Normal file
|
|
@ -0,0 +1,64 @@
|
|||
package friends_wiiu
|
||||
|
||||
import (
|
||||
"time"
|
||||
|
||||
database_wiiu "github.com/PretendoNetwork/friends-secure/database/wiiu"
|
||||
"github.com/PretendoNetwork/friends-secure/globals"
|
||||
nex "github.com/PretendoNetwork/nex-go"
|
||||
nexproto "github.com/PretendoNetwork/nex-protocols-go"
|
||||
)
|
||||
|
||||
// Notifications that are used in other files with no main file
|
||||
|
||||
func SendUserWentOfflineNotifications(client *nex.Client) {
|
||||
lastOnline := nex.NewDateTime(0)
|
||||
lastOnline.FromTimestamp(time.Now())
|
||||
|
||||
nintendoNotificationEventGeneral := nexproto.NewNintendoNotificationEventGeneral()
|
||||
|
||||
nintendoNotificationEventGeneral.U32Param = 0
|
||||
nintendoNotificationEventGeneral.U64Param1 = 0
|
||||
nintendoNotificationEventGeneral.U64Param2 = lastOnline.Value()
|
||||
nintendoNotificationEventGeneral.StrParam = ""
|
||||
|
||||
eventObject := nexproto.NewNintendoNotificationEvent()
|
||||
eventObject.Type = 10
|
||||
eventObject.SenderPID = client.PID()
|
||||
eventObject.DataHolder = nex.NewDataHolder()
|
||||
eventObject.DataHolder.SetTypeName("NintendoNotificationEventGeneral")
|
||||
eventObject.DataHolder.SetObjectData(nintendoNotificationEventGeneral)
|
||||
|
||||
stream := nex.NewStreamOut(globals.NEXServer)
|
||||
stream.WriteStructure(eventObject)
|
||||
|
||||
rmcRequest := nex.NewRMCRequest()
|
||||
rmcRequest.SetProtocolID(nexproto.NintendoNotificationsProtocolID)
|
||||
rmcRequest.SetCallID(3810693103)
|
||||
rmcRequest.SetMethodID(nexproto.NintendoNotificationsMethodProcessNintendoNotificationEvent1)
|
||||
rmcRequest.SetParameters(stream.Bytes())
|
||||
|
||||
rmcRequestBytes := rmcRequest.Bytes()
|
||||
|
||||
friendList := database_wiiu.GetUserFriendList(client.PID())
|
||||
|
||||
for i := 0; i < len(friendList); i++ {
|
||||
friendPID := friendList[i].NNAInfo.PrincipalBasicInfo.PID
|
||||
connectedUser := globals.ConnectedUsers[friendPID]
|
||||
|
||||
if connectedUser != nil {
|
||||
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.NEXServer.Send(requestPacket)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -27,7 +27,7 @@ func UpdateAndGetAllInformation(err error, client *nex.Client, callID uint32, nn
|
|||
pid := client.PID()
|
||||
|
||||
globals.ConnectedUsers[pid].NNAInfo = nnaInfo
|
||||
globals.ConnectedUsers[pid].Presence = presence
|
||||
globals.ConnectedUsers[pid].PresenceV2 = presence
|
||||
|
||||
principalPreference := database_wiiu.GetUserPrincipalPreference(pid)
|
||||
comment := database_wiiu.GetUserComment(pid)
|
||||
|
|
|
|||
|
|
@ -15,7 +15,7 @@ func UpdatePresence(err error, client *nex.Client, callID uint32, presence *nexp
|
|||
presence.Online = true // Force online status. I have no idea why this is always false
|
||||
presence.PID = client.PID() // WHY IS THIS SET TO 0 BY DEFAULT??
|
||||
|
||||
globals.ConnectedUsers[pid].Presence = presence
|
||||
globals.ConnectedUsers[pid].PresenceV2 = presence
|
||||
sendUpdatePresenceWiiUNotifications(presence)
|
||||
|
||||
rmcResponse := nex.NewRMCResponse(nexproto.FriendsWiiUProtocolID, callID)
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user