SmartFoxServer Silverlight API
SetBuddyVariables Method (varList)
Namespaces ► SmartFoxClientAPI ► SmartFoxClient ► SetBuddyVariables(Dictionary<(Of <(String, Object>)>))
Set the current user's Buddy Variables.
This method allows to set a number of properties of the current user as buddy of other users; in other words these variables will be received by the other users who have the current user as a buddy.
Buddy Variables are the best way to share user's informations with all the other users having him/her in their buddy list.: for example the nickname, the current audio track the user is listening to, etc. The most typical usage is to set a variable containing the current user status, like "available", "occupied", "away", "invisible", etc.).
Declaration Syntax

C# | Visual Basic | Visual C++

    public void SetBuddyVariables(
    	Dictionary<string, Object> varList
    )

    Public Sub SetBuddyVariables ( _
    	varList As Dictionary(Of String, Object) _
    )

    public:
    void SetBuddyVariables(
    	Dictionary<String^, Object^>^ varList
    )

Parameters

varList (Dictionary<(Of <(String, Object>)>))
  a dictionary, where the key is the name of the variable and the value is the variable's value. Buddy Variables should all be strings. If you need to use other data types you should apply the appropriate type casts.

Remarks

NOTE:
before the release of SmartFoxServer Pro v1.6.0, Buddy Variables could not be stored, and existed during the user session only. SmartFoxServer Pro v1.6.0 introduced the ability to persist (store) all Buddy Variables and the possibility to save "offline Buddy Variables" (see the following usage notes).

Usage Note:
Let's assume that three users (A, B and C) use an "instant messenger"-like application, and user A is part of the buddy lists of users B and C.
If user A sets his own variables (using the SetBuddyVariables(Dictionary<(Of <(String, Object>)>)) method), the myBuddyVars array on his client gets populated and a SFSEvent..::.OnBuddyListUpdateDelegate event is dispatched to users B and C.
User B and C can then read those variables in their own buddy lists by means of the variables property on the buddy object (which can be retrieved from the buddyList array by means of the GetBuddyById(Int32) or GetBuddyByName(String) methods).

If the buddy list's advanced security mode is used (see the SmartFoxServer server-side configuration), Buddy Variables persistence is enabled: in this way regular variables are saved when a user goes offline and they are restored (and dispatched to the other users) when their owner comes back online.
Also, setting the <offLineBuddyVariables> parameter to true, offline variables can be used: this kind of Buddy Variables is loaded regardless the buddy is online or not, providing further informations for each entry in the buddy list. A typical usage for offline variables is to define a buddy image or additional informations such as country, email, rank, etc.
To creare an offline Buddy Variable, the "$" character must be placed before the variable name.

Sends:
SFSEvent..::.OnBuddyListUpdateDelegate

History:
SmartFoxServer Pro v1.6.0 - Buddy list's advanced security mode implemented (persistent and offline Buddy Variables).

Version:
SmartFoxServer Basic (except advanced mode) / Pro

Examples
The following example shows how to set three variables containing the user's status, the current audio track the user listening to and the user's rank. The last one is an offline variable.
CopyC#

    Dictionary<string, object> bVars = new Dictionary<string, object>();
    bVars.Add("status", "away");
    bVars.Add("track", "One Of These Days");
    bVars.Add("$rank", "guru");

    smartFox.SetBuddyVariables(bVars);

See Also
myBuddyVars
SFSEvent..::.OnBuddyListUpdateDelegate

Assembly: SmartFoxClientAPI_Silverlight (Module: SmartFoxClientAPI_Silverlight) Version: 1.0.0.0 (1.0.0.0)