ISFSEvents Protocol Reference
Conforms to | IConfigLoader |
Declared in | ISFSEvents.h |
Tasks
-
– onConnection:
This event notifies the result of a connection attempt.
-
– onConnectionLost:
This event notifies of a disconnection from the Server.
-
– onConnectionRetry:
This event notifies a temporary disconnection from the Server followed by an immediate attempt to reconnect.
-
– onConectionAttempHTTP:
This event notifies an attempt to establish an HTTP tunnel connection with SmartFoxServer 2X.
-
– onConnectionResume:
This event is dispatched after a temporary disconnection, when the connection to the Server has been re-establisehd.
-
– onUDPSocketConnect:
The onUDPSocketConnect event is dispatched after a UDP connection has been attempted and either failed (0) or succedded (1) to establish a connection.
-
– onConfigLoadSuccess:
Dispatched when the external SmartFox configuration file has been loaded successfully.
-
– onConfigLoadFailure:
Dispatched when an error occurs while loading the external SmartFox configuration file.
-
– onLogin:
This event is dispatched in response to a login request.
-
– onLoginError:
This event is dispatched in response to a failed login request.
-
– onLogout:
This event is dispatched in response to a logout request.
-
– onRoomAdd:
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.
-
– onRoomRemove:
This event is dispatched whenever a Room is removed from the Zone, under any of the Room Groups that the User is listening for.
-
– onRoomCreationError:
This event is dispatched in response to a failed create room request.
-
– onRoomJoin:
This event is dispatched in response to a JoinRoomRequest.
-
– onRoomJoinError:
This event is dispatched in response to a failed JoinRoomRequest.
The params object contains the following parameters.
-
– onUserEnterRoom:
This event is fired whenever a User enters one of the Rooms where the current User is joined.
-
– onUserExitRoom:
This event is fired whenever a User leaves one of the Rooms where the current User is joined.
-
– onUserCountChange:
This event is fired whenever the number of users/spectators in a Room changes.
-
– onPublicMessage:
This event is fired when a User sends a public message.
-
– onPrivateMessage:
This event is fired when a User receives a private message.
-
– onModeratorMessage:
This event is fired when a User receives a Moderator message.
-
– onAdminMessage:
This event is fired when a User receives an Admin message.
-
– onObjectMessage:
This event is received when a User has sent an ObjectMessage request
-
– onExtensionResponse:
This event is fired every time a server-side Extension sends a message, usually in response to an ExtensionRequest.
-
– onRoomVariablesUpdate:
This event is fired in response to a SetRoomVariablesRequest
-
– onUserVariablesUpdate:
This event is fired in response to a SetUserVariablesRequest
-
– onSubscribeRoomGroup:
This event is fired in response to a SubscribeRoomGroupRequest
-
– onSubscribeRoomGroupError:
This event is fired in response to a failed SubscribeRoomGroupRequest
-
– onUnsubscribeRoomGroup:
This event is fired in response to an UnsubscribeRoomGroupRequest
-
– onUnsubscribeRoomGroupError:
This event is fired in response to a failed UnsubscribeRoomGroupRequest
-
– onSpectatorToPlayer:
This event is fired in response to a successful SpectatorToPlayerRequest
-
– onSpectatorToPlayerError:
This event is fired in response to a failed SpectatorToPlayerRequest
-
– onPlayerToSpectator:
This event is fired in response to a successful PlayerToSpectatorRequest
-
– onPlayerToSpectatorError:
This event is fired in response to a failed PlayerToSpectatorRequest
-
– onRoomNameChange:
This event is fired in response to a ChangeRoomNameRequest
-
– onRoomNameChangeError:
This event is fired in response to a failed ChangeRoomNameRequest
-
– onRoomPasswordStateChange:
This event is fired in response to a ChangeRoomPasswordStateRequest.
-
– onRoomPasswordStateChangeError:
This event is fired in response to a failed ChangeRoomPasswordStateRequest
-
– onRoomCapacityChange:
This event is fired in response to a ChangeRoomCapacityRequest
-
– onRoomCapacityChangeError:
This event is fired in response to a failed ChangeRoomCapacityRequest
-
– onRoomFindResult:
This event is fired in response to a FindRoomsRequest
-
– onUserFindResult:
This event is fired in response to a FindUsersRequest
-
– onInvitation:
This event is fired when another User has sent you an Invitation
-
– onInvitationReply:
This event is fired when a User sends a reply to your Invitation
-
– onInvitationReplyError:
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
-
– onBuddyMessage:
This event is fired in response to a BuddyMessageRequest.
-
– onBuddyListInit:
This event is fired in response to a InitBuddyListRequest.
-
– onBuddyAdd:
This event is fired in response to a AddBuddyRequest.
-
– onBuddyRemove:
This event is fired in response to a RemoveBuddyRequest.
-
– onBuddyBlock:
This event is fired in response to a BlockBuddyRequest.
-
– onBuddyOnlineStateUpdate:
This event is fired in response to a GoOnlineRequest.
-
– onBuddyVariablesUpdate:
This event is fired in response to a SetBuddyVariablesRequest.
-
– onBuddyError:
This event is fired in response to a failed Buddy request, such as AddBuddy, RemoveBuddy etc…
-
– onDebugMessage:
This event is fired in response to a console message from logger…
Instance Methods
onAdminMessage:
This event is fired when a User receives an Admin message.
- (void)onAdminMessage:(SFSEvent *)evt
Parameters
- sender
(SFSUser *) the sender of the message
- message
(NSString *) the message
- data
(SFSObject *) an object with custom data
Discussion
This event is fired when a User receives an Admin message.
-(void)onAdminMessage:(SFSEvent *)evt
{
NSLog(@"Admin says: %@", [evt.params objectForKey:@"message"]);
}
See Also
Declared In
ISFSEvents.h
onBuddyAdd:
This event is fired in response to a AddBuddyRequest.
- (void)onBuddyAdd:(SFSBuddyEvent *)evt
Parameters
- buddy
(SFSBuddy *) the Buddy that was added
Discussion
This event is fired in response to a AddBuddyRequest.
See Also
Declared In
ISFSEvents.h
onBuddyBlock:
This event is fired in response to a BlockBuddyRequest.
- (void)onBuddyBlock:(SFSBuddyEvent *)evt
Parameters
- buddy
(SFSBuddy *) the Buddy that was blocked/unblocked
Discussion
This event is fired in response to a BlockBuddyRequest.
See Also
Declared In
ISFSEvents.h
onBuddyError:
This event is fired in response to a failed Buddy request, such as AddBuddy, RemoveBuddy etc…
- (void)onBuddyError:(SFSBuddyEvent *)evt
Parameters
- errorMessage
(NSString *) the error message
Discussion
This event is fired in response to a failed Buddy request, such as AddBuddy, RemoveBuddy etc…
Declared In
ISFSEvents.h
onBuddyListInit:
This event is fired in response to a InitBuddyListRequest.
- (void)onBuddyListInit:(SFSBuddyEvent *)evt
Parameters
- buddyList
(NSArray *) a list of Buddy objects
- myVariables
(NSArray *) a list of the User’s BuddyVariable(s)
Discussion
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]);
See Also
Declared In
ISFSEvents.h
onBuddyMessage:
This event is fired in response to a BuddyMessageRequest.
- (void)onBuddyMessage:(SFSBuddyEvent *)evt
Parameters
- 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
Discussion
This event is fired in response to a BuddyMessageRequest.
See Also
Declared In
ISFSEvents.h
onBuddyOnlineStateUpdate:
This event is fired in response to a GoOnlineRequest.
- (void)onBuddyOnlineStateUpdate:(SFSBuddyEvent *)evt
Parameters
- 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
Discussion
This event is fired in response to a GoOnlineRequest.
See Also
Declared In
ISFSEvents.h
onBuddyRemove:
This event is fired in response to a RemoveBuddyRequest.
- (void)onBuddyRemove:(SFSBuddyEvent *)evt
Parameters
- buddy
(SFSBuddy *) the Buddy that was removed
Discussion
This event is fired in response to a RemoveBuddyRequest.
See Also
Declared In
ISFSEvents.h
onBuddyVariablesUpdate:
This event is fired in response to a SetBuddyVariablesRequest.
- (void)onBuddyVariablesUpdate:(SFSBuddyEvent *)evt
Parameters
- 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
Discussion
This event is fired in response to a SetBuddyVariablesRequest.
See Also
Declared In
ISFSEvents.h
onConectionAttempHTTP:
This event notifies an attempt to establish an HTTP tunnel connection with SmartFoxServer 2X.
- (void)onConectionAttempHTTP:(SFSEvent *)evt
Discussion
This event notifies an attempt to establish an HTTP tunnel connection with SmartFoxServer 2X.
The following example shows how to handle a reconnection
-(void)onConectionAttempHTTP:(SFSEvent *)evt
{
// Provide feedback to client on BlueBox(HTTP) connection attempt.
}
See Also
– onConnectionRetry:(SFSEvent *)evt
– onConnection:(SFSEvent *)evt
Declared In
ISFSEvents.h
onConfigLoadFailure:
Dispatched when an error occurs while loading the external SmartFox configuration file.
- (void)onConfigLoadFailure:(SFSEvent *)evt
Parameters
- message
(NSString *) the error message.
The following example shows how to handle a potential error in configuration loading.
[smartFox loadConfig:@"testEnvironmentConfig.xml" connectOnSuccess:YES]; function onConfigLoadFailure:(SFSEvent *)evt { NSLog(@"Failed loading config file: %@", [evt.params objectForKey:@"message"]); }
Discussion
Dispatched when an error occurs while loading the external SmartFox configuration file.
.
See Also
– onConfigLoadSuccess:(SFSEvent *)evt
Declared In
ISFSEvents.h
onConfigLoadSuccess:
Dispatched when the external SmartFox configuration file has been loaded successfully.
- (void)onConfigLoadSuccess:(SFSEvent *)evt
Discussion
Dispatched when the external SmartFox configuration file has been loaded successfully.
This event is dispatched only if the connectOnSuccess parameter of the SmartFox2XClient::loadConfig:connectOnSuccess: 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.
[smartFox loadConfig:@"testEnvironmentConfig.xml" connectOnSuccess:NO];
function onConfigLoadSuccess(evt:SFSEvent):void
{
NSLog(@"Config file loaded, now connecting...");
[smartFox connect:smartFox.currentIp port:smartFox.currentPort];
}
See Also
– onConfigLoadFailure:(SFSEvent *)evt
Declared In
ISFSEvents.h
onConnection:
This event notifies the result of a connection attempt.
- (void)onConnection:(SFSEvent *)evt
Parameters
- 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
smartFox = [[SmartFox2XClient smartFoxWithDebugMode:NO delegate:self] retain]; [smartFox loadConfig:@"config.xml" connectOnSuccess:YES]; -(void)onConnection:(SFSEvent *)evt { if ([[evt.params objectForKey:@"success"] boolValue]) { NSLog(@"Connection was established"); } else { NSLog(@"Connection failed"); } }
Discussion
This event notifies the result of a connection attempt.
See Also
– onConnectionRetry:(SFSEvent *)evt
– onConnectionResume:(SFSEvent *)evt
– onConnectionLost:(SFSEvent *)evt
Declared In
ISFSEvents.h
onConnectionLost:
This event notifies of a disconnection from the Server.
- (void)onConnectionLost:(SFSEvent *)evt
Parameters
- reason
(contains NSString) the reason of the disconnection.
The following example shows how to handle a disconnection
-(void)onConnectionLost:(SFSEvent *)evt { NSLog(@"Connection was lost, Reason: %@", [evt.params objectForKey:@"reason"]); }
Discussion
This event notifies of a disconnection from the Server.
When possible the API will also provide a reason for the disconnection:
- Idle: the connection was dropped because the User was inactive for too long
- Manual: the User requested the disconnection
- Kick: the connection was dropped because the User was kicked
- Ban: the connection was dropped because the User was banned
- Unknown: the connection was lost for reasons outside of the API (slow or bad connection, network problems etc…)
See Also
– onConnectionRetry:(SFSEvent *)evt
– onConnectionResume:(SFSEvent *)evt
– onConnection:(SFSEvent *)evt
Declared In
ISFSEvents.h
onConnectionResume:
This event is dispatched after a temporary disconnection, when the connection to the Server has been re-establisehd.
- (void)onConnectionResume:(SFSEvent *)evt
Discussion
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
-(void)onConnectionRetry:(SFSEvent *)evt
{
// Freeze your GUI and provide some feedback to the Player
}
-(void)onConnectionResume:(SFSEvent *)evt
{
// Unfreeze the GUI and let the player continue with the game...
}
-(void)onConnectionLost:(SFSEvent *)evt
{
NSLog(@"Ouch, connection was lost. Reason: %@", [evt.params objectForKey:@"reason"]);
}
See Also
– onConnectionLost:(SFSEvent *)evt
– onConnectionResume:(SFSEvent *)evt
– onConnection:(SFSEvent *)evt
Declared In
ISFSEvents.h
onConnectionRetry:
This event notifies a temporary disconnection from the Server followed by an immediate attempt to reconnect.
- (void)onConnectionRetry:(SFSEvent *)evt
Discussion
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
-(void)onConnectionRetry:(SFSEvent *)evt
{
// Freeze your GUI and provide some feedback to the Player
}
-(void)onConnectionResume:(SFSEvent *)evt
{
// Unfreeze the GUI and let the player continue with the game...
}
See Also
– onConnectionLost:(SFSEvent *)evt
– onConnectionResume:(SFSEvent *)evt
– onConnection:(SFSEvent *)evt
Declared In
ISFSEvents.h
onDebugMessage:
This event is fired in response to a console message from logger…
- (void)onDebugMessage:(LoggerEvent *)evt
Parameters
- message
(String) the debug message.
Discussion
This event is fired in response to a console message from logger…
Declared In
ISFSEvents.h
onExtensionResponse:
This event is fired every time a server-side Extension sends a message, usually in response to an ExtensionRequest.
- (void)onExtensionResponse:(SFSEvent *)evt
Parameters
- cmd
(NSString *) the name of the “command” (or “action id”) associated with the message
- params
(INSSFSObject *) custom parameters
Discussion
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)
-(void)onExtensionResponse:(SFSEvent *)evt
{
NSArray *keys = [evt.params allKeys];
for (NSString *key in keys)
{
NSLog(@"%@: %@", key, [evt.params objectForKey:key]);
}
}
See Also
Declared In
ISFSEvents.h
onInvitation:
This event is fired when another User has sent you an Invitation
- (void)onInvitation:(SFSEvent *)evt
Parameters
- invitation
(SFSInvitation *) the invitation object
Discussion
This event is fired when another User has sent you an Invitation
See Also
Declared In
ISFSEvents.h
onInvitationReply:
This event is fired when a User sends a reply to your Invitation
- (void)onInvitationReply:(SFSEvent *)evt
Parameters
- 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…)
Discussion
This event is fired when a User sends a reply to your Invitation
See Also
Declared In
ISFSEvents.h
onInvitationReplyError:
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
- (void)onInvitationReplyError:(SFSEvent *)evt
Parameters
- errorMessage
(NSString *) the error message
Discussion
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
See Also
Declared In
ISFSEvents.h
onLogin:
This event is dispatched in response to a login request.
- (void)onLogin:(SFSEvent *)evt
Parameters
- 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
-(void)onLogin:(SFSEvent *)evt { NSLog(@"Hi, I have just logged in as: %@" + [[evt.params objectForKey:@"user"] name]); }
Discussion
This event is dispatched in response to a login request.
The params object may contain the following keys.
See Also
Declared In
ISFSEvents.h
onLoginError:
This event is dispatched in response to a failed login request.
- (void)onLoginError:(SFSEvent *)evt
Parameters
- errorMessage
(NSString *) the error message
-(void)onLoginError:(SFSEvent *)evt { NSLog(@"Login Failed. Reason: %@" ,[evt.params objectForKey:@"errorMessage"]); }
Discussion
This event is dispatched in response to a failed login request.
See Also
– onLogin:(SFSEvent *)evt
Declared In
ISFSEvents.h
onLogout:
This event is dispatched in response to a logout request.
- (void)onLogout:(SFSEvent *)evt
Discussion
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:
- Send a LogoutRequest to the Server
- Handle the onLogout event on the client
- Perform a new login in the new Zone
No parameters are passed for this event
-(void)onLogout:(SFSEvent *)evt
{
NSLog(@"Logout was successful");
// Proceed with more logic here...
}
See Also
Declared In
ISFSEvents.h
onModeratorMessage:
This event is fired when a User receives a Moderator message.
- (void)onModeratorMessage:(SFSEvent *)evt
Parameters
- sender
(SFSUser *) the sender of the message
- message
(NSString *) the message
- data
(SFSObject *) an object with custom data
Discussion
This event is fired when a User receives a Moderator message.
-(void)onModeratorMessage:(SFSEvent *)evt
{
SFSUser *sender = [evt.params objectForKey:@"sender"];
NSLog(@"Moderator says: %@, from: %@", [evt.params objectForKey:@"message"], sender.name);
}
See Also
Declared In
ISFSEvents.h
onObjectMessage:
This event is received when a User has sent an ObjectMessage request
- (void)onObjectMessage:(SFSEvent *)evt
Parameters
- sender
(SFSUser *) the sender of the message
- message
(SFSObject *) the object data
Discussion
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…
-(void)onObjectMessage:(SFSEvent *)evt
{
SFSObject *obj = [evt.params objectForKey:@"message"];
NSLog(@"Received data: %@", [obj getDump]);
}
See Also
Declared In
ISFSEvents.h
onPlayerToSpectator:
This event is fired in response to a successful PlayerToSpectatorRequest
- (void)onPlayerToSpectator:(SFSEvent *)evt
Parameters
- room
(SFSRoom *) the Room where the player became a spectator
- user
(SFSUser *) the User who became a spectator
//This is how to dispatch the event -(void)switchPlayerToSpectator { [client send:[PlayerToSpectatorRequest requestWithTargetRoom:nil]]; } //This is how to handle the event -(void)onPlayerToSpectator:(SFSEvent *)evt { NSLog(@"Hi, I'm handling an onPlayerToSpectator event. My params are %@",evt.params); }
Discussion
This event is fired in response to a successful PlayerToSpectatorRequest
See Also
Declared In
ISFSEvents.h
onPlayerToSpectatorError:
This event is fired in response to a failed PlayerToSpectatorRequest
- (void)onPlayerToSpectatorError:(SFSEvent *)evt
Parameters
- errorMessage
(NSString *) the error message
//This is how to handle the event -(void)onSpectatorToPlayerError:(SFSEvent *)evt { NSLog(@"Hi, I'm handling an onPlayerToSpectatorError event. My params are %@",evt.params); }
Discussion
This event is fired in response to a failed PlayerToSpectatorRequest
See Also
Declared In
ISFSEvents.h
onPrivateMessage:
This event is fired when a User receives a private message.
- (void)onPrivateMessage:(SFSEvent *)evt
Parameters
- sender
(SFSUser *) the sender of the message
- message
(NSString *) the message
- data
(SFSObject *) an object with custom data
Discussion
This event is fired when a User receives a private message.
-(void)onPrivateMessage:(SFSEvent *)evt
{
SFSUser *sender = [evt.params objectForKey:@"sender"];
NSLog(@"PM: %@, from: %@", [evt.params objectForKey:@"message"], sender.name);
}
See Also
Declared In
ISFSEvents.h
onPublicMessage:
This event is fired when a User sends a public message.
- (void)onPublicMessage:(SFSEvent *)evt
Parameters
- room
(SFSRoom *) the target Room
- sender
(SFSUser *) the sender
- message
(NSString *) the message
- data
(SFSObject *) an object with custom data
Discussion
This event is fired when a User sends a public message.
Also the User receives this event every time he sends a public message.
-(void)onPublicMessage:(SFSEvent *)evt
{
SFSUser *sender = [evt.params objectForKey:@"sender"];
NSLog(@"%@: %@", sender.name, [evt.params objectForKey:@"message"]);
}
See Also
Declared In
ISFSEvents.h
onRoomAdd:
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.
- (void)onRoomAdd:(SFSEvent *)evt
Parameters
- room
(SFSRoom *) the room object
-(void)onRoomAdd:(SFSEvent *)evt { NSLog(@"A new Room was added: %@", [evt.params objectForKey:@"room"]); }
Discussion
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.
See Also
– onRoomRemove:(SFSEvent *)evt
Declared In
ISFSEvents.h
onRoomCapacityChange:
This event is fired in response to a ChangeRoomCapacityRequest
- (void)onRoomCapacityChange:(SFSEvent *)evt
Parameters
- room
(SFSRoom *) the Room where the change occurred
Discussion
This event is fired in response to a ChangeRoomCapacityRequest
See Also
Declared In
ISFSEvents.h
onRoomCapacityChangeError:
This event is fired in response to a failed ChangeRoomCapacityRequest
- (void)onRoomCapacityChangeError:(SFSEvent *)evt
Parameters
- errorMessage
(NSString *) the error message
Discussion
This event is fired in response to a failed ChangeRoomCapacityRequest
See Also
Declared In
ISFSEvents.h
onRoomCreationError:
This event is dispatched in response to a failed create room request.
- (void)onRoomCreationError:(SFSEvent *)evt
Parameters
- errorMessage
(NSString *) the error message
-(void)onRoomCreationError:(SFSEvent *)evt { NSLog(@"Room Creation Error: %@", [evt.params objectForKey:@"errorMessage"]); }
Discussion
This event is dispatched in response to a failed create room request.
See Also
– onRoomAdd:(SFSEvent *)evt
Declared In
ISFSEvents.h
onRoomFindResult:
This event is fired in response to a FindRoomsRequest
- (void)onRoomFindResult:(SFSEvent *)evt
Parameters
- rooms
(NSArray *) a list of Rooms matching the request criteria. If no Room was found the list will be empty.
Discussion
This event is fired in response to a FindRoomsRequest
See Also
Declared In
ISFSEvents.h
onRoomJoin:
This event is dispatched in response to a JoinRoomRequest.
- (void)onRoomJoin:(SFSEvent *)evt
Parameters
- room
(SFSRoom *) the joined Room
-(void)onRoomJoin:(SFSEvent *)evt { SFSRoom *room = [evt.params objectForKey:@"room"]; NSLog(@"The Room %@ was successfully joined!", room.name); }
Discussion
This event is dispatched in response to a JoinRoomRequest.
See Also
– onRoomJoinError:(SFSEvent *)evt
Declared In
ISFSEvents.h
onRoomJoinError:
This event is dispatched in response to a failed JoinRoomRequest.
The params object contains the following parameters.
- (void)onRoomJoinError:(SFSEvent *)evt
Parameters
- errorMessage
(NSString *) the error message
-(void)onRoomJoinError:(SFSEvent *)evt { NSLog(@"Join Room Failure: %@", [evt.params objectForKey:@"errorMessage"]); }
Discussion
This event is dispatched in response to a failed JoinRoomRequest.
The params object contains the following parameters.
See Also
– onRoomJoinError:(SFSEvent *)evt
Declared In
ISFSEvents.h
onRoomNameChange:
This event is fired in response to a ChangeRoomNameRequest
- (void)onRoomNameChange:(SFSEvent *)evt
Parameters
- room
(SFSRoom *) the Room where the change occurred
- oldName
(NSString *) the old Room name
//This is how to handle the event -(void)onRoomNameChange:(SFSEvent *)evt { NSLog(@"Hi, I'm handling an onRoomNameChange event. My params are %@",evt.params); }
Discussion
This event is fired in response to a ChangeRoomNameRequest
See Also
Declared In
ISFSEvents.h
onRoomNameChangeError:
This event is fired in response to a failed ChangeRoomNameRequest
- (void)onRoomNameChangeError:(SFSEvent *)evt
Parameters
- errorMessage
(NSString *) the error message
Discussion
This event is fired in response to a failed ChangeRoomNameRequest
See Also
Declared In
ISFSEvents.h
onRoomPasswordStateChange:
This event is fired in response to a ChangeRoomPasswordStateRequest.
- (void)onRoomPasswordStateChange:(SFSEvent *)evt
Parameters
- room
(SFSRoom *) the Room where the change occurred
Discussion
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
See Also
Declared In
ISFSEvents.h
onRoomPasswordStateChangeError:
This event is fired in response to a failed ChangeRoomPasswordStateRequest
- (void)onRoomPasswordStateChangeError:(SFSEvent *)evt
Parameters
- errorMessage
(NSString *) the error message
Discussion
This event is fired in response to a failed ChangeRoomPasswordStateRequest
See Also
Declared In
ISFSEvents.h
onRoomRemove:
This event is dispatched whenever a Room is removed from the Zone, under any of the Room Groups that the User is listening for.
- (void)onRoomRemove:(SFSEvent *)evt
Parameters
- room
(SFSRoom *) the room object
-(void)onRoomRemove:(SFSEvent *)evt { NSLog(@"A new Room was removed: %@", [evt.params objectForKey:@"room"]); }
Discussion
This event is dispatched whenever a Room is removed from the Zone, under any of the Room Groups that the User is listening for.
See Also
– onRoomAdd:(SFSEvent *)evt
Declared In
ISFSEvents.h
onRoomVariablesUpdate:
This event is fired in response to a SetRoomVariablesRequest
- (void)onRoomVariablesUpdate:(SFSEvent *)evt
Parameters
- room
(SFSRoom *) the Room in which the event occurred
- changedVars
(NSArray *) the list of variable names that where modified or created
Discussion
This event is fired in response to a SetRoomVariablesRequest
See Also
Declared In
ISFSEvents.h
onSpectatorToPlayer:
This event is fired in response to a successful SpectatorToPlayerRequest
- (void)onSpectatorToPlayer:(SFSEvent *)evt
Parameters
- 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
//This is how to dispatch the event -(void)switchSpectatorToPlayer { [client send:[SpectatorToPlayerRequest requestWithTargetRoom:nil]]; } //This is how to handle the event -(void)onSpectatorToPlayer:(SFSEvent *)evt { NSLog(@"Hi, I'm handling an onSpectatorToPlayer event. My params are %@",evt.params); }
Discussion
This event is fired in response to a successful SpectatorToPlayerRequest
See Also
Declared In
ISFSEvents.h
onSpectatorToPlayerError:
This event is fired in response to a failed SpectatorToPlayerRequest
- (void)onSpectatorToPlayerError:(SFSEvent *)evt
Parameters
- errorMessage
(NSString *) the error message
//This is how to handle the event -(void)onSpectatorToPlayerError:(SFSEvent *)evt { NSLog(@"Hi, I'm handling an onSpectatorToPlayerError event. My params are %@",evt.params); }
Discussion
This event is fired in response to a failed SpectatorToPlayerRequest
See Also
Declared In
ISFSEvents.h
onSubscribeRoomGroup:
This event is fired in response to a SubscribeRoomGroupRequest
- (void)onSubscribeRoomGroup:(SFSEvent *)evt
Parameters
- groupId
(NSString *) the name of thr group that was subscribed
- newRooms
(NSArray *) the list of rooms contained in the new group
Discussion
This event is fired in response to a SubscribeRoomGroupRequest
See Also
Declared In
ISFSEvents.h
onSubscribeRoomGroupError:
This event is fired in response to a failed SubscribeRoomGroupRequest
- (void)onSubscribeRoomGroupError:(SFSEvent *)evt
Parameters
- errorMessage
(NSString *) the error message
Discussion
This event is fired in response to a failed SubscribeRoomGroupRequest
The params object contains the following parameters.
See Also
Declared In
ISFSEvents.h
onUDPSocketConnect:
The onUDPSocketConnect event is dispatched after a UDP connection has been attempted and either failed (0) or succedded (1) to establish a connection.
- (void)onUDPSocketConnect:(SFSEvent *)evt
Discussion
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
-(void)onUDPSocketConnect:(SFSEvent *)evt
{
if ([[evt.params objectForKey:@"success"] boolValue])
{
NSLog(@"UDP connected");
}
else
{
NSLog(@"UDP not connected");
}
}
See Also
– onConnectionLost:(SFSEvent *)evt
– onConnectionResume:(SFSEvent *)evt
– onConnection:(SFSEvent *)evt
Declared In
ISFSEvents.h
onUnsubscribeRoomGroup:
This event is fired in response to an UnsubscribeRoomGroupRequest
- (void)onUnsubscribeRoomGroup:(SFSEvent *)evt
Parameters
- groupId
(NSString *) the name of the group that was unsubscribed.
Discussion
This event is fired in response to an UnsubscribeRoomGroupRequest
See Also
Declared In
ISFSEvents.h
onUnsubscribeRoomGroupError:
This event is fired in response to a failed UnsubscribeRoomGroupRequest
- (void)onUnsubscribeRoomGroupError:(SFSEvent *)evt
Parameters
- errorMessage
(NSString *) the error message
Discussion
This event is fired in response to a failed UnsubscribeRoomGroupRequest
The params object contains the following parameters.
See Also
Declared In
ISFSEvents.h
onUserCountChange:
This event is fired whenever the number of users/spectators in a Room changes.
- (void)onUserCountChange:(SFSEvent *)evt
Parameters
- room
(Room) the Room
- uCount
(NSNumber *) the new user count
- sCount
(NSNumber *) the new spectator count
Discussion
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.
-(void)onUserCountChange:(SFSEvent *)evt
{
SFSRoom *room = [evt.params objectForKey:@"room"];
int uCount = [[evt.params objectForKey:@"uCount"] intValue];
int sCount = [[evt.params objectForKey:@"sCount"] intValue];
NSLog(@"Room: %@ contains %d users and %d spectators", room.name, uCount, sCount);
}
Declared In
ISFSEvents.h
onUserEnterRoom:
This event is fired whenever a User enters one of the Rooms where the current User is joined.
- (void)onUserEnterRoom:(SFSEvent *)evt
Parameters
- user
(SFSUser *) the User object
- room
(SFSRoom *) the Room object
-(void)onUserEnterRoom:(SFSEvent *)evt { SFSRoom *room = [evt.params objectForKey:@"room"]; SFSUser *user = [evt.params objectForKey:@"user"]; NSLog(@"User: %@ has just joined Room: %@", user.name, room.name); }
Discussion
This event is fired whenever a User enters one of the Rooms where the current User is joined.
See Also
– onUserExitRoom:(SFSEvent *)evt
– onRoomJoin:(SFSEvent *)evt
Declared In
ISFSEvents.h
onUserExitRoom:
This event is fired whenever a User leaves one of the Rooms where the current User is joined.
- (void)onUserExitRoom:(SFSEvent *)evt
Parameters
- user
(SFSUser *) the User object
- room
(SFSRoom *) the Room object
-(void)onUserExitRoom:(SFSEvent *)evt { SFSRoom *room = [evt.params objectForKey:@"room"]; SFSUser *user = [evt.params objectForKey:@"user"]; NSLog(@"User: %@ has just left Room: %@", user.name, room.name); }
Discussion
This event is fired whenever a User leaves one of the Rooms where the current User is joined.
See Also
– onUserEnterRoom:(SFSEvent *)evt
– onRoomJoin:(SFSEvent *)evt
Declared In
ISFSEvents.h
onUserFindResult:
This event is fired in response to a FindUsersRequest
- (void)onUserFindResult:(SFSEvent *)evt
Parameters
- users
(NSArray *) a list of Users matching the request criteria. If no User was found the list will be empty.
Discussion
This event is fired in response to a FindUsersRequest
See Also
Declared In
ISFSEvents.h
onUserVariablesUpdate:
This event is fired in response to a SetUserVariablesRequest
- (void)onUserVariablesUpdate:(SFSEvent *)evt
Parameters
- user
(SFSUser *) the User that created or modified the Variables
- changedVars
(NSArray *) the list of variable names that where modified or created
Discussion
This event is fired in response to a SetUserVariablesRequest
See Also
Declared In
ISFSEvents.h