Toggles the current user's online/offline state as buddy in other users' buddies lists.

Namespace: Sfs2X.Requests.Buddylist
Assembly: SmartFox2X (in SmartFox2X.dll) Version: 1.7.3.0 (1.7.3)

Syntax

C#
public class GoOnlineRequest : BaseRequest

Remarks

All clients who have the current user as buddy in their buddies list will receive the BUDDY_ONLINE_STATE_UPDATE event and see the IsOnline property change accordingly. The same event is also dispatched to the current user, who sent the request, so that the application interface can be updated accordingly. Going online/offline as buddy doesn't affect the user connection, the currently joined Zone and Rooms, etc.

The online state of a user in a buddy list is handled by means of a reserved and persistent Buddy Variable.

This request can be sent if the Buddy List system was previously initialized only (see the InitBuddyListRequest request description).

Examples

The following example changes the user online state in the Buddy List system:
 Copy imageCopy
void SomeMethod() {
    sfs.AddEventListener(SFSBuddyEvent.BUDDY_ONLINE_STATE_UPDATE, OnBuddyOnlineStateUpdate);
    // Put myself offline in the Buddy List system
    sfs.Send(new GoOnlineRequest(false));
}
void OnBuddyOnlineStateUpdate(BaseEvent evt) {
    // As the state change event is dispatched to me too,
// I have to check if I am the one who changed his state
    bool isItMe = (bool)evt.Params["isItMe"];
    Buddy buddy = (Buddy)evt.Params["buddy"];
    if (isItMe)
    {
        Console.WriteLine("I'm now " + (sfs.BuddyManager.MyOnlineState ? "online" : "offline"));                        // .Net / Unity
        System.Diagnostics.Debug.WriteLine("I'm now " + (sfs.BuddyManager.MyOnlineState ? "online" : "offline"));       // Windows Universal
}
    else
    {
        Console.WriteLine("My buddy " + buddy.Name + " is now", (buddy.IsOnline ? "online" : "offline"));                       // .Net / Unity
        System.Diagnostics.Debug.WriteLine("My buddy " + buddy.Name + " is now", (buddy.IsOnline ? "online" : "offline"));      // Windows Universal
}
}

Inheritance Hierarchy

System..::..Object
  BaseRequest
    Sfs2X.Requests.Buddylist..::..GoOnlineRequest

See Also