together - TogetherGames/Public-Unity-CSharp GitHub Wiki

Together

Together::Together

Overview

The Together class is the root class in the Together api. It contains essential configuration settings, an object representing the logged in User, and various Managers for creating, deleting, and retrieving various Together objects.


Members

float PingInterval

How often the ping message is sent to the server.

DateTime LastPingTime

The last time a ping message was sent to the server.

string CacheUserGuid

The cached UserGuid of the last logged in User.

string ServerIP

The IP address of the together server.

string ClientPublicKey

The PublicKey of the Together Client the Game belongs to.

string ClientPrivateKey

The PrivateKey of the Together Client that Game belongs to.

string GameKey

The Key of the Together Game.

string PlatformName

The name of the platform the Game is running on. (IOS, Android, Mac OS, Unity, HTML5/JS)

string ApnsDeviceToken

The DeviceToken for Apple push notifications.

string GcmDeviceToken

The DeviceToken for Google push notifications.

string WnsDeviceToken

The DeviceToken for Windows push notifications.

bool RegisteredPushEnabledDevice

A boolean indicates whether the push enabled Device has been registered with the server.

User User

A User class instance representing the logged in User.

UserSession UserSession

A UserSession class instance representing the logged in UserSession.

GameInstanceManager GameInstanceManager

A GameInstanceManager class instance useful for storing GameInstances the logged in User is a member of.

LeaderboardManager LeaderboardManager

A LeaderboardManager class instance useful for storing Leaderboards.

UserNotificationManager UserNotificationManager

A UserNotificationManager class instance useful for storing UserNotifications.

AchievementManager AchievementManager

A AchievementManager class instance useful for storing Achievements.

ItemManager ItemManager

A ItemManager class instance useful for storing Items.

ChatRoomManager ChatRoomManager

A ChatRoomManager class instance useful for storing ChatRooms.

FriendUserManager FriendUserManager

A FriendUserManager class instance useful for storing together Friends.

UserPurchaseManager UserPurchaseManager

A UserPurchaseManager class instance useful for storing UserPurchases.

A TogetherSocial class instance containing various social apis.


Methods


Together()

Together constructor with thread safety option. The network processor will execute your callbacks when performing network operations tailored for either a thread safe environment (Such as Windows Desktop builds or Mac Desktop builds) or circumvent an environment that is not guaranteed to be thread safe(Such us Unity). Use the constructor to specify which kind environment you are working within. If you are unsure, use False. If the environment is set to False(Not thread safe), then Process() must be called on the Network Processor to invoke callbacks from network methods.

Returns void
Syntax
Together.Together( theadSafe )
Parameters

bool theadSafe

TRUE identifies that the environment is thread safe, FALSE identifies it is not

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

Initialize()

Initializes the Together class so it's ready for the developer to start calling network messages.

Returns void
Syntax
Together.Initialize( clientPublicKey, clientPrivateKey, gameKey, platformName )
Parameters

string clientPublicKey

The PublicKey of the Client whose game this is. This is accessable from the playstogether website.

[string](#) clientPrivateKey

The PrivateKey of the Client whose game this is. This is accessable from the playstogether website.

[string](#) gameKey

The GameKey of the game. This is accessable from the playstogether website.

[string](#) platformName

The Name of the Platform the game is running on. Supported Platforms are: ("IOS", "Android", "Mac OS", "Unity", "HTML5/JS")

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

SetServerAddress()

Sets the ServerAddress all network messages will be sent to when talking to the together servers. This defaults to the primary Together servers and does not need to be called unless you are working with a form of private/local server instance. If you are interested in private hosting and want more information, contact [email protected].

Returns void
Syntax
Together.SetServerAddress( serverAddress )
Parameters

string serverAddress

The server address of the together server.

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

GetServerAddress()

Gets the ServerAddress all network messages will be sent to when talking to the together servers.

Returns string
Syntax
Together.GetServerAddress(  )

GetUserID()

Gets the UserID of the logged in User.

Returns long
Syntax
Together.GetUserID(  )

GetNameOfUser()

Gets the Name of the logged in User.

Returns string
Syntax
Together.GetNameOfUser(  )

GetUsername()

Gets the Username of the logged in User.

Returns string
Syntax
Together.GetUsername(  )

GetSessionToken()

Gets the SessionToken of the UserSession returned when logging in.

Returns string
Syntax
Together.GetSessionToken(  )

FindTogetherFriendByUserID()

Finds the TogetherFriend with the specified UserID.

Returns FriendUser
Syntax
Together.FindTogetherFriendByUserID( userID )
Parameters

long userID

The ID of User to retrieve.

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

FindFacebookFriendBySocialID()

Finds the FacebookFriend with the specified SocialID (FacebookID).

Syntax
Together.FindFacebookFriendBySocialID( socialID )
Parameters

string socialID

The FacebookID of the facebook user to find.

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

Print()

Prints out the specified text to the log.

Returns void
Syntax
Together.Print( text )
Parameters

string text

The text to print out.

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

LoadTogetherCache()

Loads the Together Cache from the Device. The only thing stored in the TogetherCache currently is the UserGuid of the last logged in user for the application.

Returns bool
Syntax
Together.LoadTogetherCache(  )

SaveTogetherCache()

Saves the Together Cache to the Device. The only thing stored in the TogetherCache currently is the UserGuid of the last logged in user for the application.

Returns bool
Syntax
Together.SaveTogetherCache(  )

EraseTogetherCache()

Erases the Together Cache from the Device. The only thing stored in the TogetherCache currently is the UserGuid of the last logged in user for the application.

Returns bool
Syntax
Together.EraseTogetherCache(  )

LoginUser()

Logs in the User. This should always be the first Together network message called. If no User GUID is provided, a new user account will be created anonymously and assigned a GUID which can be used to log the user in again later or register them with Facebook or via Custom form.

Note
Currently anonymous users will NOT be deleted. However it is possible that a user cleansing system will be implemented in the future that removes unregistered accounts after 3 to 6 months of inactivity.

Returns void
Syntax
Together.LoginUser( callbackFunc )
Parameters

OnCompleteHandler callbackFunc

The function to call upon completion.

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

GetServerTimeUTC()

Gets the Server Timestamp(UTC+0). The timestamp will be returned in the data member of the callback as a long.

Returns void
Syntax
Together.GetServerTimeUTC( callbackFunc )
Parameters

OnCompleteHandler callbackFunc

The function to call upon completion.

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

GetGlobalProfile()

Fetches your developer global profile of data set through the portal or by atomic operations. The callback object will contain the profile in the data member as a PropertyCollection type.

Returns void
Syntax
Together.GetGlobalProfile( callbackFunc )
Parameters

OnCompleteHandler callbackFunc

The function to call upon completion.

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

GetGameProfile()

Fetches the game's profile of data set through the portal or by atomic operations. The callback object will contain the profile in the data member as a PropertyCollection type.

Returns void
Syntax
Together.GetGameProfile( callbackFunc )
Parameters

OnCompleteHandler callbackFunc

The function to call upon completion.

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

GetUserProfile()

Fetches the current, logged in user's profile for the game. The callback object will contain the profile in the data member as a PropertyCollection type. This is also retrieved when the User object for the local player is fetched and can be modified with the User.Modify call.

Returns void
Syntax
Together.GetUserProfile( callbackFunc )
Parameters

OnCompleteHandler callbackFunc

The function to call upon completion.

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

AddAtomic()

Adds an atomic field to either the game profile or the global profile. The callback object will contain a Property type in the data field.

Returns void
Syntax
Together.AddAtomic( global, parentName, propertyName, propertyValue, callbackFunc )
Parameters

boolean global

Pass TRUE to add the atomic entry to the global profile, FALSE to add it to the game profile

[string](#) parentName

The name of an existing parent collection in which to add the atomic entry to

[string](#) propertyName

The name of the atomic field to add

[string](#) propertyValue

The value of the atomic entry to apply

[OnCompleteHandler](./oncompletehandler) callbackFunc

The function to call upon completion.

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

IncrementAtomic()

Increments an existing atomic property in either the game profile or global profile without an upper limit. The callback object will contain a Property type in the data field.

Returns void
Syntax
Together.IncrementAtomic( global, parentName, propertyName, callbackFunc )
Parameters

boolean global

Pass TRUE to increment an entry in the global profile, FALSE to increment an entry in the game profile

[string](#) parentName

The name of an existing parent collection containing the property

[string](#) propertyName

The name of the property to increment

[OnCompleteHandler](./oncompletehandler) callbackFunc

The function to call upon completion.

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

IncrementAtomicWithLimit()

Increments an existing atomic property in either the game profile or global profile with a passed upper limit. The callback object will contain a Property type in the data field.

Returns void
Syntax
Together.IncrementAtomicWithLimit( global, parentName, propertyName, limit, callbackFunc )
Parameters

boolean global

Pass TRUE to increment an entry in the global profile, FALSE to increment an entry in the game profile

[string](#) parentName

The name of an existing parent collection containing the property

[string](#) propertyName

The name of the property to increment

[number](#) limit

The upper limit of the atomic operation as an integer

[OnCompleteHandler](./oncompletehandler) callbackFunc

The function to call upon completion.

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

IncrementAtomicWithLimitRef()

Increments an existing atomic property in either the game profile or global profile with a reference to a limit elsewhere in the profile. The callback object will contain a Property type in the data field.

Returns void
Syntax
Together.IncrementAtomicWithLimitRef( global, parentName, propertyName, refParent, refProperty, callbackFunc )
Parameters

boolean global

Pass TRUE to increment an entry in the global profile, FALSE to increment an entry in the game profile

[string](#) parentName

The name of an existing parent collection containing the property

[string](#) propertyName

The name of the property to increment

[string](#) refParent

The name of the parent collection containing the property to be used as the limit

[string](#) refProperty

The name of the property in the referenced parent to be used as the limit

[OnCompleteHandler](./oncompletehandler) callbackFunc

The function to call upon completion.

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

RegisterFacebook()

Registers the User with Facebook. TogetherSocialFacebook:Login() calls this method upon successfully logging into facebook.

Returns void
Syntax
Together.RegisterFacebook( facebookID, name, firstName, lastName, link, username, gender, locale, The )
Parameters

string facebookID

The FacebookID of the facebook user.

[string](#) name

The name of the facebook user.

[string](#) firstName

The first name of the facebook user.

[string](#) lastName

The last name of the facebook user.

[string](#) link

The link to the facebook user.

[string](#) username

The username of the facebook user.

[string](#) gender

The gender of the facebook user.

[string](#) locale

The locale of the facebook user.

[OnCompleteHandler](./oncompletehandler) The

function to call upon completion.

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

RegisterCustom()

Registers the User with the custom registration system.

Returns void
Syntax
Together.RegisterCustom( email, password, name, callbackFunc )
Parameters

string email

The email of the Custom user.

[string](#) password

The password of the Custom user. This does not automatically hash the password. Use an MD5 or SHA hash before calling this.

[string](#) name

The name of the Custom user.

[OnCompleteHandler](./oncompletehandler) callbackFunc

The function to call upon completion.

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

Logout()

Logs out the User. If the user did not registered, this will mark the account inactive but is reactivated at the next login with the same user GUID.

Note
Currently anonymous users will NOT be deleted. However it is possible that a user cleansing system will be implemented in the future that removes unregistered accounts after 3 to 6 months of inactivity.

Returns void
Syntax
Together.Logout( callbackFunc )
Parameters

OnCompleteHandler callbackFunc

The function to call upon completion.

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

RegisterPushEnabledDevice()

Registers a push enabled Device. Use by setting ApnsDeviceToken and/or GcmDeviceToken and/or WnsDeviceToken first then calling.

Note
If you are using Unity, this registratino is handled for you via the DeviceRegistrar script

Returns void
Syntax
Together.RegisterPushEnabledDevice( callbackFunc )
Parameters

OnCompleteHandler callbackFunc

The function to call upon completion.

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

UnRegisterPushEnabledDevice()

Unregisters a push enabled Device. Use by setting ApnsDeviceToken to "0" and/or GcmDeviceToken to "0" and/or WnsDeviceToken to "0" first then calling.

Returns void
Syntax
Together.UnRegisterPushEnabledDevice( callbackFunc )
Parameters

OnCompleteHandler callbackFunc

The function to call upon completion.

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

SendPushNotification()[1]

Sends a push notification message.

Note
This counts towards Push Notifications on your developer account and does not count as a System Request.

Returns void
Syntax
Together.SendPushNotification[1]( destUserID, notification, callbackFunc )
Parameters

long destUserID

The ID of the User to send the push notification to.

[TogetherNotification](./togethernotification) notification

The together notification data to be sent to the Together Servers.

[OnCompleteHandler](./oncompletehandler) callbackFunc

The function to call upon completion.

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

SendPushNotification()[2]

Sends a push notification message.

Note
This counts towards Push Notifications on your developer account and does not count as a System Request.

Returns void
Syntax
Together.SendPushNotification[2]( destUserID, notification, callbackFunc )
Parameters

long destUserID

The ID of the User to send the push notification to.

[string](#) notification

The together notification data to be sent to the Together Servers.

[OnCompleteHandler](./oncompletehandler) callbackFunc

The function to call upon completion.

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

Ping()

Pings the Server for the User as a keep-alive.

Returns void
Syntax
Together.Ping( callbackFunc )
Parameters

OnCompleteHandler callbackFunc

The function to call upon completion.

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

AddAnalytic()

Adds an Analytic event for the User with simple options.

Returns void
Syntax
Together.AddAnalytic( eventName, propName, propValue, callbackFunc )
Parameters

string eventName

The name of the event to assign to the analytic record.

[string](#) propName

The name of the property to assign to the analytic record.

[string](#) propValue

The value of the property to assign to the analytic record.

[OnCompleteHandler](./oncompletehandler) callbackFunc

The function to call upon completion.

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

AddAnalyticEx()

Adds an Analytic event for the User with extended options.

Returns void
Syntax
Together.AddAnalyticEx( eventName, propertyCollection, callbackFunc )
Parameters

string eventName

The name of the event to assign to the analytic record.

[PropertyCollection](./propertycollection) propertyCollection

Collection of data to add to the event record

[OnCompleteHandler](./oncompletehandler) callbackFunc

The function to call upon completion.

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