SFS2X Objective-C API
1.7.13
iOS / macOS / tvOS
|
Inherits <IConfigLoader>.
|
optional |
This event is fired when a User receives an Admin message.
sender | (SFSUser *) the sender of the message |
message | (NSString *) the message |
data | (SFSObject *) an object with custom data |
|
optional |
This event is fired in response to a AddBuddyRequest.
|
optional |
This event is fired in response to a BlockBuddyRequest.
|
optional |
This event is fired in response to a failed Buddy request, such as AddBuddy, RemoveBuddy etc...
errorMessage | (NSString *) the error message |
|
optional |
This event is fired in response to a InitBuddyListRequest.
After the Buddy List initialization the User will return to his previous Buddy state. His online/offline status, the Buddy state and his persistent Buddy Variables will all be loaded and broadcast in the system. In particular the online status determines if the User will appear online or not to other Users that have added him/her to their lists.
At this stage the custom Buddy states are also loaded and populated locally by the API.
NSLog(@"Buddy States: " + [smartFox.buddyManager buddyStates]);
|
optional |
This event is fired in response to a BuddyMessageRequest.
buddy | (SFSBuddy *) the Buddy that updated the BuddyVariables |
isItMe | (NSNumber *) true if the Buddy is actually the current User |
message | (NSString *) a list with the names of the Variables that where changed/set |
data | (SFSObject *) optional custom parameters |
|
optional |
This event is fired in response to a GoOnlineRequest.
buddy | (SFSBuddy *) the Buddy that was has changed his online status |
isItMe | (NSNumber *) (contains a BOOL value) true if the Buddy is actually the current User |
|
optional |
This event is fired in response to a RemoveBuddyRequest.
|
optional |
This event is fired in response to a SetBuddyVariablesRequest.
buddy | (SFSBuddy *) the Buddy that updated the BuddyVariables |
changedVars | (NSArray *) a list with the names of the Variables that where changed/set |
isItMe | (NSNumber *) true if the Buddy is actually the current User |
|
optional |
This event notifies an attempt to establish an HTTP tunnel connection with SmartFoxServer 2X.
The following example shows how to handle a reconnection
|
optional |
Dispatched when an error occurs while loading the external SmartFox configuration file.
message | (NSString *) the error message. |
The following example shows how to handle a potential error in configuration loading.
|
optional |
Dispatched when the external SmartFox configuration file has been loaded successfully.
This event is dispatched only if the connectOnSuccess parameter of the loadConfig:connectOnSuccess: (SmartFox2XClient) method is set to NO; otherwise the connection is made and the related onConnection: event is fired.
No parameters are provided.
The following example shows how to handle a successful configuration loading.
|
optional |
This event notifies the result of a connection attempt.
success | (contains an NSNumber with BOOL in it) true if a connection was established, false otherwise. |
The following example shows how to start a connection
|
optional |
This event notifies of a disconnection from the Server.
When possible the API will also provide a reason for the disconnection:
reason | (contains NSString) the reason of the disconnection. |
The following example shows how to handle a disconnection
|
optional |
This event is dispatched after a temporary disconnection, when the connection to the Server has been re-establisehd.
SmartFoxServer 2X provides a powerful new feature that allows a broken connection to be re-established transparently without loosing any of the current application state. This allows any player to get back in the game without fear of loosing the match because of a sloppy internet connection or a sudden disconnection.
In case the re-connection attempts fail onConnectionLost: event will be fired.
The following example shows how to handle a reconnection
|
optional |
This event notifies a temporary disconnection from the Server followed by an immediate attempt to reconnect.
SmartFoxServer 2X provides a powerful new feature that allows a broken connection to be re-established transparently without loosing any of the current application state. This allows any player to get back in the game without fear of loosing the match because of a sloppy internet connection.
When this event is dispatched the API enter a "freeze" mode where no new requests can be sent until the reconnection is successfully performed. It is highly recommended to handle this event and freeze your application interface accordingly until the onConnectionResume: event is fired.
The following example shows how to handle a reconnection
|
optional |
This event is fired in response to a server side InitCrypto request.
NOTE: It is necessary to send this request right after a successful connection event, before login.
Example:
The code below allows to easily toggle the use of encryption for local vs production testing.
|
optional |
This event is fired in response to a console message from the logger
message | (String) the debug message. |
|
optional |
This event is fired every time a server-side Extension sends a message, usually in response to an ExtensionRequest.
(A server Extension can send messages at any moment, not just in response to a specific client request)
cmd | (NSString *) the name of the "command" (or "action id") associated with the message |
params | (SFSObject *) custom parameters |
room | (id<Room>) the Room which the Extension is attached to (for Room Extensions only) |
|
optional |
This event is fired when another User has sent you an Invitation
invitation | (SFSInvitation *) the invitation object |
|
optional |
This event is fired when a User sends a reply to your Invitation
invitee | (SFSUser) the User that was invited |
reply | (NSNumber *) the reply code. It can be either InvitationReply.ACCEPT or InvitationReply.REFUSE |
data | (SFSObject *) additional custom paramters (e.g. a reason for the refusal, a message etc...) |
|
optional |
This event is fired in response to a failed InvitationReplyRequest The failure is usually caused by a late reply which doesn't make it to the server within the expected time
errorMessage | (NSString *) the error message |
|
optional |
This event is dispatched in response to a login request.
The params object may contain the following keys.
user | (SFSUser *) the User object |
zone | (NSString *) the zone |
data | (SFSObject *) a custom object with extra params (if you have added custom server side logic) |
The following example shows how to handle a login event
|
optional |
This event is dispatched in response to a failed login request.
errorMessage | (NSString *) the error message |
|
optional |
This event is dispatched in response to a logout request.
Usually this event needs to be handled when you want to logout from the current Zone and join another one. In order to perform the operation correctly you need to do as follows:
No parameters are passed for this event
|
optional |
This event is fired in response to a server side SetMMOItemVariables.
room | (SFSRoom*) the room in which the event occurred |
mmoItem | (MMOItem*) the item whose variables where changed |
changedVars | (NSArray*) an array of variable names that were changed |
The following example shows how handle the event:
|
optional |
This event is fired when a User receives a Moderator message.
sender | (SFSUser *) the sender of the message |
message | (NSString *) the message |
data | (SFSObject *) an object with custom data |
|
optional |
This event is received when a User has sent an ObjectMessage request
The object sent by the sender can contain custom data, such as a game move etc...
|
optional |
This event is fired at regular intervals when the LagMonitor is active
lagValue | (NSNumber) the average of the last measured lag values, expressed in milliseconds. |
|
optional |
This event is fired in response to a successful PlayerToSpectatorRequest
room | (SFSRoom *) the Room where the player became a spectator |
user | (SFSUser *) the User who became a spectator |
|
optional |
This event is fired in response to a failed PlayerToSpectatorRequest
errorMessage | (NSString *) the error message |
|
optional |
This event is fired when a User receives a private message.
sender | (SFSUser *) the sender of the message |
message | (NSString *) the message |
data | (SFSObject *) an object with custom data |
|
optional |
This event is fired in response to a SetUserPositionRequest.
addedUsers | (NSArray *) A list of User objects representing the users who entered the current user's Area of Interest. |
removedUsers | (NSArray *) A list of User objects representing the users who left the current user's Area of Interest. |
addedItems | (NSArray *) A list of MMOItem objects which entered the current user's Area of Interest. |
removedItems | (NSArray *) A list of MMOItem objects which left the current user's Area of Interest. |
room | (SFSRoom*) The room where the event occurred |
The following example shows how to set the position in virtual world and handle the proximity list event:
|
optional |
This event is fired when a User sends a public message.
Also the User receives this event every time he sends a public message.
room | (SFSRoom *) the target Room |
sender | (SFSUser *) the sender |
message | (NSString *) the message |
data | (SFSObject *) an object with custom data |
|
optional |
This event is dispatched when a new Room was created inside the Zone under any of the Room Groups that the User is listening for.
The params object contains the following keys.
room | (SFSRoom *) the room object |
|
optional |
This event is fired in response to a ChangeRoomCapacityRequest
|
optional |
This event is fired in response to a failed ChangeRoomCapacityRequest
errorMessage | (NSString *) the error message |
|
optional |
This event is dispatched in response to a failed create room request.
errorMessage | (NSString *) the error message |
|
optional |
This event is fired in response to a FindRoomsRequest
rooms | (NSArray *) a list of Rooms matching the request criteria. If no Room was found the list will be empty. |
|
optional |
This event is dispatched in response to a JoinRoomRequest.
|
optional |
This event is dispatched in response to a failed JoinRoomRequest.
The params object contains the following parameters.
errorMessage | (NSString *) the error message |
|
optional |
This event is fired in response to a ChangeRoomNameRequest
|
optional |
This event is fired in response to a failed ChangeRoomNameRequest
errorMessage | (NSString *) the error message |
|
optional |
This event is fired in response to a ChangeRoomPasswordStateRequest.
In particular this event when the password state is changed. For example when a non-password protected Room is assigned a password, or vice-versa
|
optional |
This event is fired in response to a failed ChangeRoomPasswordStateRequest
errorMessage | (NSString *) the error message |
|
optional |
This event is dispatched whenever a Room is removed from the Zone, under any of the Room Groups that the User is listening for.
room | (SFSRoom *) the room object |
|
optional |
This event is fired in response to a SetRoomVariablesRequest
|
optional |
This event is fired in response to a successful SpectatorToPlayerRequest
room | (SFSRoom *) the Room where the spectator became a player |
user | (SFSUser *) the User who became a player |
playerId | (NSNumber *) the new playerId of the User |
|
optional |
This event is fired in response to a failed SpectatorToPlayerRequest
errorMessage | (NSString *) the error message |
|
optional |
This event is fired in response to a SubscribeRoomGroupRequest
groupId | (NSString *) the name of thr group that was subscribed |
newRooms | (NSArray *) the list of rooms contained in the new group |
|
optional |
This event is fired in response to a failed SubscribeRoomGroupRequest
The params object contains the following parameters.
errorMessage | (NSString *) the error message |
|
optional |
The onUDPSocketConnect event is dispatched after a UDP connection has been attempted and either failed (0) or succedded (1) to establish a connection.
The client will attempt to connect three (3) time before dispatching a failed event.
The following example shows how to handle the event
|
optional |
This event is fired in response to an UnsubscribeRoomGroupRequest
groupId | (NSString *) the name of the group that was unsubscribed. |
|
optional |
This event is fired in response to a failed UnsubscribeRoomGroupRequest
The params object contains the following parameters.
errorMessage | (NSString *) the error message |
|
optional |
This event is fired whenever the number of users/spectators in a Room changes.
The client receives updates for all Rooms inside the Room Groups that he is listening to.
|
optional |
This event is fired whenever a User enters one of the Rooms where the current User is joined.
|
optional |
This event is fired whenever a User leaves one of the Rooms where the current User is joined.
|
optional |
This event is fired in response to a FindUsersRequest
users | (NSArray *) a list of Users matching the request criteria. If no User was found the list will be empty. |
|
optional |
This event is fired in response to a SetUserVariablesRequest