mirror of
https://github.com/PretendoNetwork/friends.git
synced 2026-04-25 15:36:34 -05:00
Update other files
Update other main files to add more functionality
This commit is contained in:
parent
cb6ff5bf25
commit
b0215272ce
|
|
@ -36,9 +36,17 @@ func assignNEXProtocols() {
|
|||
// Friends (3DS) protocol handles
|
||||
friends3DSServer.UpdateProfile(friends_3ds.UpdateProfile)
|
||||
friends3DSServer.UpdateMii(friends_3ds.UpdateMii)
|
||||
friends3DSServer.UpdatePreference(friends_3ds.UpdatePreference)
|
||||
friends3DSServer.UpdatePreference(friends_3ds.UpdatePreferences)
|
||||
friends3DSServer.SyncFriend(friends_3ds.SyncFriend)
|
||||
friends3DSServer.UpdatePresence(friends_3ds.UpdatePresence)
|
||||
friends3DSServer.UpdateFavoriteGameKey(friends_3ds.UpdateFavoriteGameKey)
|
||||
friends3DSServer.UpdateComment(friends_3ds.UpdateComment)
|
||||
friends3DSServer.AddFriendByPrincipalID(friends_3ds.AddFriendshipByPrincipalID)
|
||||
friends3DSServer.GetFriendPersistentInfo(friends_3ds.GetFriendPersistentInfo)
|
||||
friends3DSServer.GetFriendMii(friends_3ds.GetFriendMii)
|
||||
friends3DSServer.GetFriendPresence(friends_3ds.GetFriendPresence)
|
||||
friends3DSServer.RemoveFriendByPrincipalID(friends_3ds.RemoveFriendByPrincipalID)
|
||||
friends3DSServer.RemoveFriendByLocalFriendCode(friends_3ds.RemoveFriendByLocalFriendCode)
|
||||
friends3DSServer.GetPrincipalIDByLocalFriendCode(friends_3ds.GetPrincipalIDByLocalFriendCode)
|
||||
friends3DSServer.GetAllFriends(friends_3ds.GetAllFriends)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,9 +1,6 @@
|
|||
package main
|
||||
|
||||
import (
|
||||
"time"
|
||||
|
||||
database_wiiu "github.com/PretendoNetwork/friends-secure/database/wiiu"
|
||||
"github.com/PretendoNetwork/friends-secure/globals"
|
||||
nex "github.com/PretendoNetwork/nex-go"
|
||||
)
|
||||
|
|
@ -53,10 +50,4 @@ func connect(packet *nex.PacketV0) {
|
|||
connectedUser.PID = packet.Sender().PID()
|
||||
connectedUser.Client = packet.Sender()
|
||||
globals.ConnectedUsers[userPID] = connectedUser
|
||||
|
||||
lastOnline := nex.NewDateTime(0)
|
||||
lastOnline.FromTimestamp(time.Now())
|
||||
|
||||
// TODO: CHANGE THIS. NOT EVERY CONNECTION IS FROM WIIU
|
||||
database_wiiu.UpdateUserLastOnlineTime(packet.Sender().PID(), lastOnline)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -6,10 +6,12 @@ import (
|
|||
)
|
||||
|
||||
type ConnectedUser struct {
|
||||
PID uint32
|
||||
Client *nex.Client
|
||||
NNAInfo *nexproto.NNAInfo
|
||||
Presence *nexproto.NintendoPresenceV2
|
||||
PID uint32
|
||||
Platform uint8
|
||||
Client *nex.Client
|
||||
NNAInfo *nexproto.NNAInfo
|
||||
Presence *nexproto.NintendoPresence
|
||||
PresenceV2 *nexproto.NintendoPresenceV2
|
||||
}
|
||||
|
||||
func NewConnectedUser() *ConnectedUser {
|
||||
|
|
|
|||
59
main.go
59
main.go
|
|
@ -2,12 +2,6 @@ package main
|
|||
|
||||
import (
|
||||
"sync"
|
||||
"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"
|
||||
)
|
||||
|
||||
var wg sync.WaitGroup
|
||||
|
|
@ -20,56 +14,3 @@ func main() {
|
|||
|
||||
wg.Wait()
|
||||
}
|
||||
|
||||
// Maybe this function should go in a different file?
|
||||
func sendUserWentOfflineWiiUNotifications(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)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -5,8 +5,11 @@ import (
|
|||
"os"
|
||||
"time"
|
||||
|
||||
friends_3ds "github.com/PretendoNetwork/friends-secure/3ds"
|
||||
database_3ds "github.com/PretendoNetwork/friends-secure/database/3ds"
|
||||
database_wiiu "github.com/PretendoNetwork/friends-secure/database/wiiu"
|
||||
"github.com/PretendoNetwork/friends-secure/globals"
|
||||
friends_wiiu "github.com/PretendoNetwork/friends-secure/wiiu"
|
||||
nex "github.com/PretendoNetwork/nex-go"
|
||||
)
|
||||
|
||||
|
|
@ -30,27 +33,28 @@ func startNEXServer() {
|
|||
|
||||
globals.NEXServer.On("Kick", func(packet *nex.PacketV0) {
|
||||
pid := packet.Sender().PID()
|
||||
delete(globals.ConnectedUsers, pid)
|
||||
|
||||
if globals.ConnectedUsers[pid] == nil {
|
||||
return
|
||||
}
|
||||
|
||||
platform := globals.ConnectedUsers[pid].Platform
|
||||
lastOnline := nex.NewDateTime(0)
|
||||
lastOnline.FromTimestamp(time.Now())
|
||||
|
||||
database_wiiu.UpdateUserLastOnlineTime(pid, lastOnline)
|
||||
sendUserWentOfflineWiiUNotifications(packet.Sender())
|
||||
if platform == 1 {
|
||||
database_wiiu.UpdateUserLastOnlineTime(pid, lastOnline)
|
||||
friends_wiiu.SendUserWentOfflineNotifications(packet.Sender())
|
||||
} else if platform == 2 {
|
||||
database_3ds.UpdateUserLastOnlineTime(pid, lastOnline)
|
||||
friends_3ds.SendUserWentOfflineNotificationsGlobally(packet.Sender())
|
||||
}
|
||||
|
||||
delete(globals.ConnectedUsers, pid)
|
||||
fmt.Println("Leaving (Kick)")
|
||||
})
|
||||
|
||||
globals.NEXServer.On("Disconnect", func(packet *nex.PacketV0) {
|
||||
pid := packet.Sender().PID()
|
||||
delete(globals.ConnectedUsers, pid)
|
||||
|
||||
lastOnline := nex.NewDateTime(0)
|
||||
lastOnline.FromTimestamp(time.Now())
|
||||
|
||||
database_wiiu.UpdateUserLastOnlineTime(pid, lastOnline)
|
||||
sendUserWentOfflineWiiUNotifications(packet.Sender())
|
||||
|
||||
fmt.Println("Leaving (Disconnect)")
|
||||
})
|
||||
|
||||
|
|
|
|||
|
|
@ -2,15 +2,33 @@ package main
|
|||
|
||||
import (
|
||||
"strconv"
|
||||
"time"
|
||||
|
||||
database_3ds "github.com/PretendoNetwork/friends-secure/database/3ds"
|
||||
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"
|
||||
)
|
||||
|
||||
func registerEx(err error, client *nex.Client, callID uint32, stationUrls []*nex.StationURL, loginData nexproto.NintendoLoginData) {
|
||||
func registerEx(err error, client *nex.Client, callID uint32, stationUrls []*nex.StationURL, loginData *nex.DataHolder) {
|
||||
// TODO: Validate loginData
|
||||
|
||||
pid := client.PID()
|
||||
user := globals.ConnectedUsers[pid]
|
||||
lastOnline := nex.NewDateTime(0)
|
||||
lastOnline.FromTimestamp(time.Now())
|
||||
|
||||
if loginData.TypeName() == "NintendoLoginData" {
|
||||
user.Platform = 1 // Platform is Wii U
|
||||
|
||||
database_wiiu.UpdateUserLastOnlineTime(pid, lastOnline)
|
||||
} else if loginData.TypeName() == "AccountExtraInfo" {
|
||||
user.Platform = 2 // Platform is 3DS
|
||||
|
||||
database_3ds.UpdateUserLastOnlineTime(pid, lastOnline)
|
||||
}
|
||||
|
||||
localStation := stationUrls[0]
|
||||
|
||||
address := client.Address().IP.String()
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user