Package sfs2x.client.requests.buddylist
Class GoOnlineRequest
- java.lang.Object
-
- sfs2x.client.requests.BaseRequest
-
- sfs2x.client.requests.buddylist.GoOnlineRequest
-
- All Implemented Interfaces:
sfs2x.client.requests.IRequest
public class GoOnlineRequest extends BaseRequest
Toggles the current user's online/offline state as buddy in other users' buddies lists.All clients who have the current user as buddy in their buddies list will receive the buddyOnlineStateChange event and see the Buddy.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.
NOTE: this request can be sent if the Buddy List system was previously initialized only (see the InitBuddyListRequest request description).
Example
The following example changes the user online state in the Buddy List system:private void someMethod() { sfs.addEventListener(SFSBuddyEvent.BUDDY_ONLINE_STATE_UPDATE, new IEventListener() { public void dispatch(BaseEvent evt) throws SFSException { // As the state change event is dispatched to me too, // I have to check if I am the one who changed his state boolean isItMe = (Boolean) evt.getArguments().get("isItMe"); if (isItMe) System.out.println("I'm now" + (sfs.getBuddyManager().getMyOnlineState() ? "online" : "offline")); else System.out.println("My buddy " + ((Buddy)evt.getArguments().get("buddy")).getName() + " is now" + (((Buddy)evt.getArguments().get("buddy")).isOnline() ? "online" : "offline" )); } }); // Put myself offline in the Buddy List system sfs.send(new GoOnlineRequest(false)); }
-
-
Field Summary
Fields Modifier and Type Field Description static java.lang.String
KEY_BUDDY_ID
* API internal usage only *static java.lang.String
KEY_BUDDY_NAME
* API internal usage only *static java.lang.String
KEY_ONLINE
* API internal usage only *-
Fields inherited from class sfs2x.client.requests.BaseRequest
AddBuddy, AdminMessage, AutoJoin, BanUser, BlockBuddy, CallExtension, ChangeRoomCapacity, ChangeRoomName, ChangeRoomPassword, ClusterInviteUsers, ClusterJoinOrCreate, CreateRoom, CreateSFSGame, FindRooms, FindUsers, GameServerConnectionRequired, GenericMessage, GetRoomList, GoOnline, Handshake, InitBuddyList, InvitationReply, InviteUser, JoinRoom, JoinRoomInvite, KEY_ERROR_CODE, KEY_ERROR_PARAMS, KickUser, LeaveRoom, Login, Logout, ManualDisconnection, ModeratorMessage, ObjectMessage, PingPong, PlayerToSpectator, PrivateMessage, PublicMessage, QuickJoinGame, QuickJoinOrCreateRoom, RemoveBuddy, SetBuddyVariables, SetRoomVariables, SetUserPosition, SetUserVariables, SpectatorToPlayer, SubscribeRoomGroup, UnsubscribeRoomGroup
-
-
Constructor Summary
Constructors Constructor Description GoOnlineRequest(boolean online)
Creates a new GoOnlineRequest instance.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
execute(ISmartFox sfs)
* API internal usage only *void
validate(ISmartFox sfs)
* API internal usage only *-
Methods inherited from class sfs2x.client.requests.BaseRequest
getId, getMessage, getTargetController, isEncrypted, setEncrypted, setId, setTargetController
-
-
-
-
Field Detail
-
KEY_ONLINE
public static final java.lang.String KEY_ONLINE
* API internal usage only *- See Also:
- Constant Field Values
-
KEY_BUDDY_NAME
public static final java.lang.String KEY_BUDDY_NAME
* API internal usage only *- See Also:
- Constant Field Values
-
KEY_BUDDY_ID
public static final java.lang.String KEY_BUDDY_ID
* API internal usage only *- See Also:
- Constant Field Values
-
-
Constructor Detail
-
GoOnlineRequest
public GoOnlineRequest(boolean online)
Creates a new GoOnlineRequest instance. The instance must be passed to the SmartFox.send() method for the request to be performed.- Parameters:
online
-true
to make the current user available (online) in the Buddy List system;false
to make him not available (offline).- See Also:
SmartFox.send(sfs2x.client.requests.IRequest)
-
-
Method Detail
-
validate
public void validate(ISmartFox sfs) throws sfs2x.client.exceptions.SFSValidationException
* API internal usage only *- Throws:
sfs2x.client.exceptions.SFSValidationException
-
execute
public void execute(ISmartFox sfs) throws com.smartfoxserver.v2.exceptions.SFSException
* API internal usage only *- Throws:
com.smartfoxserver.v2.exceptions.SFSException
-
-