friendmanager - TogetherGames/Public-Corona-Lua GitHub Wiki

FriendManager

together.FriendManager

Overview

The FriendManager class contains a collection of Friends.


Members

table Friends

Stores all the Friends contained in the Manager.

table FriendsDictionaryByUserID

A table used to store all together friends in a dictionary form by their UserID.

table FriendsDictionaryBySocialID

A table used to store all together friends in a dictionary form by their SocialID.


Methods


Add()

Adds a TogetherFriend to the manager internally without persistence.

Note
This method is deprecated

Returns void
Syntax
FriendManager:Add( friend )
Parameters

TogetherFriend friend

Instance of the TogetherFriend to add

--------------------------------------------------------------------------------

FindByUserID()

Finds a TogetherFriend by UserID if it exists, otherwise returns nil.

Syntax
FriendManager:FindByUserID( userID )
Parameters

number userID

The ID of the User to find

--------------------------------------------------------------------------------

FindBySocialID()

Finds the TogetherFriend by SocialID if it exists, otherwise returns nil.

Syntax
FriendManager:FindBySocialID( socialID )
Parameters

number socialID

The SocialID of the User to find

--------------------------------------------------------------------------------

GetCount()

Gets the number of TogetherFriends currently managed internally.

Returns number
Syntax
FriendManager:GetCount(  )

Get()

Gets the TogetherFriend at the specified index if it exists, otherwise returns nil.

Syntax
FriendManager:Get( index )
Parameters

number index

The index of the Friend to find

--------------------------------------------------------------------------------

IndexOf()

Gets the Index of the specified Friend if it exists, otherwise returns nil.

Returns number
Syntax
FriendManager:IndexOf( friend )
Parameters

TogetherFriend friend

Instance of the Friend to get the index of

--------------------------------------------------------------------------------

IndexOfByUserID()

Returns the index of the TogetherFriend with the specified UserID if it exists, otherwise returns -1.

Returns number
Syntax
FriendManager:IndexOfByUserID( userID )
Parameters

number userID

The ID of the User to get the index of

--------------------------------------------------------------------------------

Remove()

Removes a TogetherFriend from the internally managed list. This does not delete the Friend from the user's list persistently.

Note
This method is deprecated

Returns void
Syntax
FriendManager:Remove( index )
Parameters

number index

The index of the FriendUse to be removed internally

--------------------------------------------------------------------------------

AddFriend()

Adds a new friend to the current session's User account. Upon success, this will automatically update the internal list.

Returns void
Syntax
FriendManager:AddFriend( friendUserID, callbackFunc )
Parameters

number friendUserID

The ID of the User to add as a friend

[function](#) callbackFunc

The function to call upon completion.

--------------------------------------------------------------------------------

GetAll()

Gets all Friends from the current session's User account. Upon success, this will automatically update the internal list.

Returns void
Syntax
FriendManager:GetAll( callbackFunc )
Parameters

function callbackFunc

The function to call upon completion.

--------------------------------------------------------------------------------

RemoveFriend()

Removes a Friend from the current session's User account. Upon success, this will automatically update the internal list.

Returns void
Syntax
FriendManager:RemoveFriend( friendUserID, callbackFunc )
Parameters

number friendUserID

The ID of a User to remove as a friend

[function](#) callbackFunc

The function to call upon completion.

--------------------------------------------------------------------------------

SynchFriends()

Synchronizes the Friend list. This method is called whenever you initially log into Facebook. For each Facebook friend, if they are also a registered Together User, they become a Together friend on the User account. Upon success, this will automatically update the internal list.

Returns void
Syntax
FriendManager:SynchFriends( The, externalFriends, callbackFunc )
Parameters

string The

type of synchronization to be done. Pass "FB" for Facebook. This parameter exists for future expandability to other social networks.

[table](#) externalFriends

The array full of external (Facebook) friends.

[function](#) callbackFunc

The function to call upon completion.

--------------------------------------------------------------------------------
⚠️ **GitHub.com Fallback** ⚠️