Click or drag to resize

GoOnlineRequest Class

Toggles the current user's online/offline state as buddy in other users' buddies lists.
Inheritance Hierarchy
SystemObject
  BaseRequest
    Sfs2X.Requests.BuddylistGoOnlineRequest

Namespace:  Sfs2X.Requests.Buddylist
Assembly:  SmartFox2X (in SmartFox2X.dll) Version: 1.8.0.0 (1.8.0)
Syntax
C#
public class GoOnlineRequest : BaseRequest

The GoOnlineRequest type exposes the following members.

Constructors
  NameDescription
Public methodGoOnlineRequest
Creates a new GoOnlineRequest instance.
Top
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:
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"));       // UWP
    }
    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"));      // UWP
    }
}
See Also