SmartFoxServer 2X C++ API
 All Classes Functions Variables
Sfs2X::Core::SFSEvent Class Reference

This is the main SmartFox Event class. All major system events are found here. More...

#include <SFSEvent.h>

Inheritance diagram for Sfs2X::Core::SFSEvent:
Sfs2X::Core::BaseEvent

Static Public Attributes

static boost::shared_ptr< string > UDP_INIT
 The Event notifies the result of the initial UDP handshake. More...
 
static boost::shared_ptr< string > CONNECTION
 The Event notifies the result of a connection attempt. More...
 
static boost::shared_ptr< string > PING_PONG
 
static boost::shared_ptr< string > SFS_SOCKET_ERROR
 
static boost::shared_ptr< string > CONNECTION_LOST
 The Event notifies the disconnection from the Server. More...
 
static boost::shared_ptr< string > CONNECTION_RETRY
 The Event notifies the disconnection from the Server. More...
 
static boost::shared_ptr< string > CONNECTION_RESUME
 The Event is dispatched after a temporary disconnection, when the connection to the Server has been re-establisehd. More...
 
static boost::shared_ptr< string > CONFIG_LOAD_SUCCESS
 Dispatched when the external SmartFox configuration file has been loaded successfully. More...
 
static boost::shared_ptr< string > CONFIG_LOAD_FAILURE
 Dispatched when an error occurs while loading the external SmartFox configuration file. More...
 
static boost::shared_ptr< string > LOGIN
 The Event is dispatched in response to a login request. More...
 
static boost::shared_ptr< string > LOGIN_ERROR
 The Event is dispatched in response to a failed login request. More...
 
static boost::shared_ptr< string > LOGOUT
 The Event is dispatched in response to a logout request. More...
 
static boost::shared_ptr< string > ROOM_ADD
 The Event is dispatched when a new Room was created inside the Zone under any of the Room Groups that the User is listening for. More...
 
static boost::shared_ptr< string > ROOM_REMOVE
 The Event is dispatched whenever a Room is removed from the Zone, under any of the Room Groups that the User is listening for. More...
 
static boost::shared_ptr< string > ROOM_CREATION_ERROR
 The Event is dispatched in response to a failed create room request. More...
 
static boost::shared_ptr< string > ROOM_JOIN
 The Event is dispatched in response to a JoinRoomRequest. More...
 
static boost::shared_ptr< string > ROOM_JOIN_ERROR
 The Event is dispatched in response to a failed JoinRoomRequest. More...
 
static boost::shared_ptr< string > USER_ENTER_ROOM
 The Event is fired whenever a User enters one of the Rooms where the current User is joined. More...
 
static boost::shared_ptr< string > USER_EXIT_ROOM
 The Event is fired whenever a User leaves one of the Rooms where the current User is joined. More...
 
static boost::shared_ptr< string > USER_COUNT_CHANGE
 The Event is fired whenever the number of users/spectators in a Room changes. More...
 
static boost::shared_ptr< string > PUBLIC_MESSAGE
 The Event is fired when a User sends a public message. More...
 
static boost::shared_ptr< string > PRIVATE_MESSAGE
 The Event is fired when a User receives a private message. More...
 
static boost::shared_ptr< string > MODERATOR_MESSAGE
 The Event is fired when a User receives a Moderator message. More...
 
static boost::shared_ptr< string > ADMIN_MESSAGE
 The Event is fired when a User receives an Admin message. More...
 
static boost::shared_ptr< string > OBJECT_MESSAGE
 This Event is received when a User has sent an ObjectMessage request More...
 
static boost::shared_ptr< string > EXTENSION_RESPONSE
 The Event is fired every time a server-side Extension sends a message, usually in response to an ExtensionRequest. More...
 
static boost::shared_ptr< string > ROOM_VARIABLES_UPDATE
 The Event is fired in response to a SetRoomVariablesRequest More...
 
static boost::shared_ptr< string > USER_VARIABLES_UPDATE
 The Event is fired in response to a SetUserVariablesRequest More...
 
static boost::shared_ptr< string > ROOM_GROUP_SUBSCRIBE
 The Event is fired in response to a SubscribeRoomGroupRequest More...
 
static boost::shared_ptr< string > ROOM_GROUP_UNSUBSCRIBE
 The Event is fired in response to an UnsubscribeRoomGroupRequest More...
 
static boost::shared_ptr< string > ROOM_GROUP_SUBSCRIBE_ERROR
 The Event is fired in response to a failed SubscribeRoomGroupRequest More...
 
static boost::shared_ptr< string > ROOM_GROUP_UNSUBSCRIBE_ERROR
 The Event is fired in response to a failed UnsubscribeRoomGroupRequest More...
 
static boost::shared_ptr< string > SPECTATOR_TO_PLAYER
 The Event is fired in response to a successful SpectatorToPlayerRequest More...
 
static boost::shared_ptr< string > PLAYER_TO_SPECTATOR
 The Event is fired in response to a failed PlayerToSpectatorRequest More...
 
static boost::shared_ptr< string > SPECTATOR_TO_PLAYER_ERROR
 The Event is fired in response to a failed SpectatorToPlayerRequest More...
 
static boost::shared_ptr< string > PLAYER_TO_SPECTATOR_ERROR
 The Event is fired in response to a failed UnsubscribeRoomGroupRequest More...
 
static boost::shared_ptr< string > ROOM_NAME_CHANGE
 The Event is fired in response to a ChangeRoomNameRequest More...
 
static boost::shared_ptr< string > ROOM_NAME_CHANGE_ERROR
 The Event is fired in response to a failed ChangeRoomNameRequest More...
 
static boost::shared_ptr< string > ROOM_PASSWORD_STATE_CHANGE
 The Event is fired in response to a ChangeRoomPasswordStateRequest. More...
 
static boost::shared_ptr< string > ROOM_PASSWORD_STATE_CHANGE_ERROR
 The Event is fired in response to a failed ChangeRoomPasswordStateRequest More...
 
static boost::shared_ptr< string > ROOM_CAPACITY_CHANGE
 The Event is fired in response to a ChangeRoomCapacityRequest More...
 
static boost::shared_ptr< string > ROOM_CAPACITY_CHANGE_ERROR
 The Event is fired in response to a failed ChangeRoomCapacityRequest More...
 
static boost::shared_ptr< string > ROOM_FIND_RESULT
 The Event is fired in response to a FindRoomsRequest More...
 
static boost::shared_ptr< string > USER_FIND_RESULT
 The Event is fired in response to a FindUsersRequest More...
 
static boost::shared_ptr< string > INVITATION
 The Event is fired when another User has sent you an Invitation More...
 
static boost::shared_ptr< string > INVITATION_REPLY
 The Event is fired when a User sends a reply to your Invitation More...
 
static boost::shared_ptr< string > INVITATION_REPLY_ERROR
 The Event is fired in response to a failed InvitationReplyRequest More...
 
static boost::shared_ptr< string > DEBUG_MESSAGE
 Event fired for all log messages More...
 
static boost::shared_ptr< string > PROXIMITY_LIST_UPDATE
 Dispatched when one more users or one or more MMOItem objects enter/leave the current user's Area of Interest in MMORooms. More...
 
static boost::shared_ptr< string > MMOITEM_VARIABLES_UPDATE
 Dispatched when an MMOItem Variable is updated in an MMORoom. More...
 

Additional Inherited Members

- Public Member Functions inherited from Sfs2X::Core::BaseEvent
boost::shared_ptr< map< string,
boost::shared_ptr< void > > > 
Params ()
 A Hashtable containing the event's parameters. More...
 

Detailed Description

This is the main SmartFox Event class. All major system events are found here.

See Also
SFSBuddyEvent

Member Data Documentation

boost::shared_ptr< string > Sfs2X::Core::SFSEvent::ADMIN_MESSAGE
static

The Event is fired when a User receives an Admin message.

The BaseEvent.Params object contains the following parameters.

parameter description
sender (User) the sender of the message
message (String) the message
data (ISFSObject) an object with custom data

The following example shows how to handle the event

ptrSmartFox->AddEventListener(SFSEvent::ADMIN_MESSAGE, boost::shared_ptr<EventListenerDelegate> (new EventListenerDelegate(CMyClass::OnAdminMessage, (unsigned long long)this)));
static void OnAdminMessage(unsigned long long ptrContext, boost::shared_ptr<BaseEvent> ptrEvent);
void CMyClass::OnAdminMessage(unsigned long long ptrContext, boost::shared_ptr<BaseEvent> ptrEvent)
{
// Get the pointer to my class
CMyClass* instance = (CMyClass*)ptrContext;
// Get the message parameter of the event
boost::shared_ptr<map<string, boost::shared_ptr<void>>> ptrEventParams = ptrEvent->Params();
boost::shared_ptr<void> ptrEventParamValueMessage = (*ptrEventParams)["message"];
boost::shared_ptr<string> ptrNotifiedMessage = ((boost::static_pointer_cast<string>))(ptrEventParamValueMessage);
}
See Also
Requests.AdminMessageRequest
boost::shared_ptr< string > Sfs2X::Core::SFSEvent::CONFIG_LOAD_FAILURE
static

Dispatched when an error occurs while loading the external SmartFox configuration file.

Typically this event is received when the configuration is not found or its not accessible (no read permissions)

The following example shows how to handle a potential error in configuration loading.

ptrSmartFox->AddEventListener(SFSEvent::CONFIG_LOAD_FAILURE, boost::shared_ptr<EventListenerDelegate> (new EventListenerDelegate(CMyClass::OnConfigLoadFailure, (unsigned long long)this)));
ptrSmartFox->LoadConfig(".\\Configuration\\testEnvironmentConfig.xml", true);
static void OnConfigLoadFailure(unsigned long long ptrContext, boost::shared_ptr<BaseEvent> ptrEvent);
void CMyClass::OnConfigLoadFailure(unsigned long long ptrContext, boost::shared_ptr<BaseEvent> ptrEvent)
{
// Get the pointer to my class
CMyClass* instance = (CMyClass*)ptrContext;
// Failed loading config file.
}
See Also
CONFIG_LOAD_SUCCESS, SmartFox.LoadConfig(string, bool)
boost::shared_ptr< string > Sfs2X::Core::SFSEvent::CONFIG_LOAD_SUCCESS
static

Dispatched when the external SmartFox configuration file has been loaded successfully.

This event is dispatched only if the connectOnSuccess parameter of the SmartFox.LoadConfig(string*, bool) method is set to false otherwise the connection is made and the related CONNECTION event is fired.

No parameters are provided.

The following example shows how to handle a successful configuration loading.

ptrSmartFox->AddEventListener(SFSEvent::CONFIG_LOAD_SUCCESS, boost::shared_ptr<EventListenerDelegate> (new EventListenerDelegate(CMyClass::OnConfigLoadSuccess, (unsigned long long)this)));
ptrSmartFox->LoadConfig(".\\Configuration\\testEnvironmentConfig.xml", true);
static void OnConfigLoadSuccess(unsigned long long ptrContext, boost::shared_ptr<BaseEvent> ptrEvent);
void CMyClass::OnConfigLoadSuccess(unsigned long long ptrContext, boost::shared_ptr<BaseEvent> ptrEvent)
{
// Get the pointer to my class
CMyClass* instance = (CMyClass*)ptrContext;
// Config file loaded, connection in progress
}
See Also
CONFIG_LOAD_FAILURE, SmartFox.LoadConfig(string, bool)
boost::shared_ptr< string > Sfs2X::Core::SFSEvent::CONNECTION
static

The Event notifies the result of a connection attempt.

The BaseEvent.Params object contains the following parameters.

parameter description
success (bool) true if a connection was established, false otherwise

The following example shows how to start a connection

boost::shared_ptr<Sfs2X::SmartFox> ptrSmartFox;
ptrSmartFox = boost::shared_ptr<Sfs2X::SmartFox>(new Sfs2X::SmartFox());
ptrSmartFox->AddEventListener(SFSEvent::CONNECTION, boost::shared_ptr<EventListenerDelegate> (new EventListenerDelegate(CMyClass::OnConnection, (unsigned long long)this)));
static void OnConnection(unsigned long long ptrContext, boost::shared_ptr<BaseEvent> ptrEvent);
void CMyClass::OnConnection(unsigned long long ptrContext, boost::shared_ptr<BaseEvent> ptrEvent)
{
// Get the pointer to my class
CMyClass* instance = (CMyClass*)ptrContext;
boost::shared_ptr<map<string, boost::shared_ptr<void>>> ptrEventParams = ptrEvent->Params();
boost::shared_ptr<void> ptrEventParamValueSuccess = (*ptrEventParams)["success"];
boost::shared_ptr<bool> ptrValue = (boost::static_pointer_cast<bool>)(ptrEventParamValueSuccess);
if (*ptrValue == true)
{
// Connection was established
}
else
{
// Connection failed
}
}
See Also
CONNECTION_RETRY, CONNECTION_RESUME, CONNECTION_LOST
boost::shared_ptr< string > Sfs2X::Core::SFSEvent::CONNECTION_LOST
static

The Event notifies the 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...)

The BaseEvent.Params object contains the following parameters.

parameter description
reason (String) the reason of the disconnection.

The following example shows how to handle a disconnection

boost::shared_ptr<Sfs2X::SmartFox> ptrSmartFox;
ptrSmartFox = boost::shared_ptr<Sfs2X::SmartFox>(new Sfs2X::SmartFox());
ptrSmartFox->AddEventListener(SFSEvent::CONNECTION_LOST, boost::shared_ptr<EventListenerDelegate> (new EventListenerDelegate(CMyClass::OnConnectionLost, (unsigned long long)this)));
static void OnConnectionLost(unsigned long long ptrContext, boost::shared_ptr<BaseEvent> ptrEvent);
void CMyClass::OnConnectionLost(unsigned long long ptrContext, boost::shared_ptr<BaseEvent> ptrEvent)
{
// Get the pointer to my class
CMyClass* instance = (CMyClass*)ptrContext;
boost::shared_ptr<map<string, boost::shared_ptr<void>>> ptrEventParams = ptrEvent->Params();
boost::shared_ptr<void> ptrEventParamValueReason = (*ptrEventParams)["reason"];
boost::shared_ptr<string> message (new string("Connection was lost, Reason: " + *((boost::static_pointer_cast<string>)(ptrEventParamValueReason))));
}
See Also
CONNECTION_RETRY, CONNECTION_RESUME, CONNECTION
boost::shared_ptr< string > Sfs2X::Core::SFSEvent::CONNECTION_RESUME
static

The 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 fails an CONNECTION_LOST event will be fired.

The following example shows how to handle a reconnection

boost::shared_ptr<Sfs2X::SmartFox> ptrSmartFox;
ptrSmartFox = boost::shared_ptr<Sfs2X::SmartFox>(new Sfs2X::SmartFox());
ptrSmartFox->AddEventListener(SFSEvent::CONNECTION_RETRY, boost::shared_ptr<EventListenerDelegate> (new EventListenerDelegate(CMyClass::OnConnectionRetry, (unsigned long long)this)));
ptrSmartFox->AddEventListener(SFSEvent::CONNECTION_RESUME, boost::shared_ptr<EventListenerDelegate> (new EventListenerDelegate(CMyClass::OnConnectionResumed, (unsigned long long)this)));
ptrSmartFox->AddEventListener(SFSEvent::CONNECTION_LOST, boost::shared_ptr<EventListenerDelegate> (new EventListenerDelegate(CMyClass::OnConnectionLost, (unsigned long long)this)));
static void OnConnectionRetry(unsigned long long ptrContext, boost::shared_ptr<BaseEvent> ptrEvent);
static void OnConnectionResumed(unsigned long long ptrContext, boost::shared_ptr<BaseEvent> ptrEvent);
static void OnConnectionLost(unsigned long long ptrContext, boost::shared_ptr<BaseEvent> ptrEvent);
void CMyClass::OnConnectionRetry(unsigned long long ptrContext, boost::shared_ptr<BaseEvent> ptrEvent)
{
// Get the pointer to my class
CMyClass* instance = (CMyClass*)ptrContext;
// Freeze your GUI and provide some feedback to the Player
}
void CMyClass::OnConnectionResumed(unsigned long long ptrContext, boost::shared_ptr<BaseEvent> ptrEvent)
{
// Get the pointer to my class
CMyClass* instance = (CMyClass*)ptrContext;
// Unfreeze the GUI and let the player continue with the game...
}
void CMyClass::OnConnectionLost(unsigned long long ptrContext, boost::shared_ptr<BaseEvent> ptrEvent)
{
// Get the pointer to my class
CMyClass* instance = (CMyClass*)ptrContext;
boost::shared_ptr<map<string, boost::shared_ptr<void>>> ptrEventParams = ptrEvent->Params();
boost::shared_ptr<void> ptrEventParamValueReason = (*ptrEventParams)["reason"];
boost::shared_ptr<string> message (new string("Connection was lost, Reason: " + *((boost::static_pointer_cast<string>)(ptrEventParamValueReason))));
}
See Also
CONNECTION_LOST, CONNECTION_RESUME, CONNECTION
boost::shared_ptr< string > Sfs2X::Core::SFSEvent::CONNECTION_RETRY
static

The Event notifies the disconnection from the Server.

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 CONNECTION_RESUME event is fired.

The following example shows how to handle a reconnection

boost::shared_ptr<Sfs2X::SmartFox> ptrSmartFox;
ptrSmartFox = boost::shared_ptr<Sfs2X::SmartFox>(new Sfs2X::SmartFox());
ptrSmartFox->AddEventListener(SFSEvent::CONNECTION_RETRY, boost::shared_ptr<EventListenerDelegate> (new EventListenerDelegate(CMyClass::OnConnectionRetry, (unsigned long long)this)));
ptrSmartFox->AddEventListener(SFSEvent::CONNECTION_RESUME, boost::shared_ptr<EventListenerDelegate> (new EventListenerDelegate(CMyClass::OnConnectionResumed, (unsigned long long)this)));
static void OnConnectionRetry(unsigned long long ptrContext, boost::shared_ptr<BaseEvent> ptrEvent);
static void OnConnectionResumed(unsigned long long ptrContext, boost::shared_ptr<BaseEvent> ptrEvent);
void CMyClass::OnConnectionRetry(unsigned long long ptrContext, boost::shared_ptr<BaseEvent> ptrEvent)
{
// Get the pointer to my class
CMyClass* instance = (CMyClass*)ptrContext;
// Freeze your GUI and provide some feedback to the Player
}
void CMyClass::OnConnectionResumed(unsigned long long ptrContext, boost::shared_ptr<BaseEvent> ptrEvent)
{
// Get the pointer to my class
CMyClass* instance = (CMyClass*)ptrContext;
// Unfreeze the GUI and let the player continue with the game...
}
See Also
CONNECTION_LOST, CONNECTION_RESUME, CONNECTION
boost::shared_ptr< string > Sfs2X::Core::SFSEvent::DEBUG_MESSAGE
static

Event fired for all log messages

Unity API only

The BaseEvent.Params object contains the following parameters.

parameter description
message (String) the log message
ptrSmartFox->AddEventListener(LogLevel::LOGLEVEL_DEBUG, boost::shared_ptr<EventListenerDelegate> (new EventListenerDelegate(CMyClass::OnDebugMessage, (unsigned long long)this)));
static void OnDebugMessage(unsigned long long ptrContext, boost::shared_ptr<BaseEvent> ptrEvent);
void CMyClass::OnDebugMessage(unsigned long long ptrContext, boost::shared_ptr<BaseEvent> ptrEvent)
{
// Get the pointer to my class
CMyClass* instance = (CMyClass*)ptrContext;
// Get the message parameter of the event
boost::shared_ptr<map<string, boost::shared_ptr<void>>> ptrEventParams = ptrEvent->Params();
boost::shared_ptr<void> ptrEventParamValueMessage = (*ptrEventParams)["message"];
boost::shared_ptr<string> ptrNotifiedMessage = ((boost::static_pointer_cast<string>))(ptrEventParamValueMessage);
}
boost::shared_ptr< string > Sfs2X::Core::SFSEvent::EXTENSION_RESPONSE
static

The 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

The BaseEvent.Params object contains the following parameters.

parameter description
cmd (String) the name of the "command" (or "action id") associated with the message
sourceRoom (int) The id of the room where the server extension is attached to.
params (ISFSObject) custom parameters
packetId (long) (optional) the id of the packet for an UDP message, the id is an auto increment value sent by the server. It can be used to detect out of order UDP packets.
See Also
Requests.ExtensionRequest, Entities.Data.SFSObject
boost::shared_ptr< string > Sfs2X::Core::SFSEvent::INVITATION
static

The Event is fired when another User has sent you an Invitation

The BaseEvent.Params object contains the following parameters.

parameter description
invitation (Invitation) the invitation object
See Also
Requests.Game.InviteUsersRequest, Entities.Invitation.SFSInvitation
boost::shared_ptr< string > Sfs2X::Core::SFSEvent::INVITATION_REPLY
static

The Event is fired when a User sends a reply to your Invitation

The BaseEvent.Params object contains the following parameters.

parameter description
invitee (User) the User that was invited
reply (int) the reply code. It can be either InvitationReply.ACCEPT or InvitationReply.REFUSE
data (ISFSObject) additional custom paramters (e.g. a reason for the refusal, a message etc...)
See Also
Entities.Invitation.InvitationReply, Requests.Game.InviteUsersRequest
boost::shared_ptr< string > Sfs2X::Core::SFSEvent::INVITATION_REPLY_ERROR
static

The 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

The BaseEvent.Params object contains the following parameters.

parameter description
errorMessage (string) the error message
errorCode (short) the error code
See Also
Requests.Game.InvitationReplyRequest, Requests.Game.InviteUsersRequest
boost::shared_ptr< string > Sfs2X::Core::SFSEvent::LOGIN
static

The Event is dispatched in response to a login request.

The BaseEvent.Params object contains the following parameters.

parameter description
user (User) the User object
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

ptrSmartFox->AddEventListener(SFSEvent::LOGIN, boost::shared_ptr<EventListenerDelegate> (new EventListenerDelegate(CMyClass::OnLogin, (unsigned long long)this)));
static void OnLogin(unsigned long long ptrContext, boost::shared_ptr<BaseEvent> ptrEvent);
void CMyClass::OnLogin(unsigned long long ptrContext, boost::shared_ptr<BaseEvent> ptrEvent)
{
// Get the pointer to my class
CMyClass* instance = (CMyClass*)ptrContext;
boost::shared_ptr<void> ptrEventParamValueUser= (*ptrEventParams)["user"];
boost::shared_ptr<User> ptrNotifiedUser = ((boost::static_pointer_cast<User>))(ptrEventParamValueUser);
boost::shared_ptr<string> message (new string("Hi, I have just logged in as: " + ptrNotifiedUser->Name()));
}
See Also
LOGIN_ERROR, Requests.LoginRequest
boost::shared_ptr< string > Sfs2X::Core::SFSEvent::LOGIN_ERROR
static

The Event is dispatched in response to a failed login request.

The BaseEvent.Params object contains the following parameters.

parameter description
errorMessage (string) the error message
errorCode (short) the error code

The following example shows how to handle a login failure event

ptrSmartFox->AddEventListener(SFSEvent::LOGIN_ERROR, boost::shared_ptr<EventListenerDelegate> (new EventListenerDelegate(CMyClass::OnLoginError, (unsigned long long)this)));
static void OnLoginError(unsigned long long ptrContext, boost::shared_ptr<BaseEvent> ptrEvent);
void CMyClass::OnLoginError(unsigned long long ptrContext, boost::shared_ptr<BaseEvent> ptrEvent)
{
// Get the pointer to my class
CMyClass* instance = (CMyClass*)ptrContext;
boost::shared_ptr<void> ptrEventParamValueMessage = (*ptrEventParams)["errorMessage"];
boost::shared_ptr<string> ptrNotifiedMessage = ((boost::static_pointer_cast<string>))(ptrEventParamValueMessage);
boost::shared_ptr<string> message (new string("Login Failed. Reason: " + *ptrNotifiedMessage));
}
See Also
LOGIN, Requests.LoginRequest
boost::shared_ptr< string > Sfs2X::Core::SFSEvent::LOGOUT
static

The 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

The following example shows how to handle a logout event

ptrSmartFox->AddEventListener(SFSEvent::LOGOUT, boost::shared_ptr<EventListenerDelegate> (new EventListenerDelegate(CMyClass::OnLogout, (unsigned long long)this)));
static void OnLogout(unsigned long long ptrContext, boost::shared_ptr<BaseEvent> ptrEvent);
void CMyClass::OnLogout(unsigned long long ptrContext, boost::shared_ptr<BaseEvent> ptrEvent)
{
// Get the pointer to my class
CMyClass* instance = (CMyClass*)ptrContext;
// Logout was successful
// Proceed with more logic here...
}
See Also
Requests.LogoutRequest, Requests.LoginRequest
boost::shared_ptr< string > Sfs2X::Core::SFSEvent::MMOITEM_VARIABLES_UPDATE
static

Dispatched when an MMOItem Variable is updated in an MMORoom.

This event is caused by an MMOItem Variable being set, updated or deleted in a server side Extension, and it is received only if the current user has the related MMOItem in his Area of Interest.

The BaseEvent.Params object contains the following parameters:

Parameter Description
room (Sfs2X.Entities.MMORoom) The MMORoom where the MMOItem whose Variables have been updated is located.
mmoItem (Sfs2X.Entities.MMOItem) The MMOItem whose variables have been updated.
changedVars (boost::shared_ptr<vector<boost::shared_ptr<string> > >) The list of names of the MMOItem Variables that were changed (or created for the first time).

The following example shows how to handle the MMOItem Variable update:

boost::shared_ptr<Sfs2X::SmartFox> ptrSmartFox;
ptrSmartFox = boost::shared_ptr<Sfs2X::SmartFox>(new Sfs2X::SmartFox());
ptrSmartFox->AddEventListener(SFSEvent::MMOITEM_VARIABLES_UPDATE, boost::shared_ptr<EventListenerDelegate> (new EventListenerDelegate(CMyClass::OnMMOItemVarsUpdate, (unsigned long long)this)));
static void OnMMOItemVarsUpdate(unsigned long long ptrContext, boost::shared_ptr<BaseEvent> ptrEvent);
void CMyClass::OnMMOItemVarsUpdate(unsigned long long ptrContext, boost::shared_ptr<BaseEvent> ptrEvent)
{
// Get the pointer to my class
CMyClass* instance = (CMyClass*)ptrContext;
boost::shared_ptr<map<string, boost::shared_ptr<void>>> ptrEventParams = ptrEvent->Params();
boost::shared_ptr<vector <boost::shared_ptr<string> > > ptrEventParamValueChangedVars = (*ptrEventParams)["changedVars"];
boost::shared_ptr<IMMOItem> ptrEventParamValueMMOItem = (*ptrEventParams)["mmoItem"];
// Check if the MMOItem was moved
if ((std::find(changedVars->begin(), changedVars->end(), "x") != changedVars->end()) || (std::find(changedVars->begin(), changedVars->end(), "y") != changedVars->end()))
{
// Move the sprite representing the MMOItem
...
}
}
See Also
Sfs2X.Entities.Variables.MMOItemVariable, Sfs2X.Entities.MMOItem, Sfs2X.Entities.MMORoom
boost::shared_ptr< string > Sfs2X::Core::SFSEvent::MODERATOR_MESSAGE
static

The Event is fired when a User receives a Moderator message.

The BaseEvent.Params object contains the following parameters.

parameter description
sender (User) the sender of the message
message (String) the message
data (ISFSObject) an object with custom data

The following example shows how to handle the event

ptrSmartFox->AddEventListener(SFSEvent::MODERATOR_MESSAGE, boost::shared_ptr<EventListenerDelegate> (new EventListenerDelegate(CMyClass::OnModeratorMessage, (unsigned long long)this)));
static void OnModeratorMessage(unsigned long long ptrContext, boost::shared_ptr<BaseEvent> ptrEvent);
void CMyClass::OnModeratorMessage(unsigned long long ptrContext, boost::shared_ptr<BaseEvent> ptrEvent)
{
// Get the pointer to my class
CMyClass* instance = (CMyClass*)ptrContext;
// Get the sender parameter of the event
// Get the message parameter of the event
boost::shared_ptr<map<string, boost::shared_ptr<void>>> ptrEventParams = ptrEvent->Params();
boost::shared_ptr<void> ptrEventParamValueSender = (*ptrEventParams)["sender"];
boost::shared_ptr<User> ptrNotifiedUser = ((boost::static_pointer_cast<User>))(ptrEventParamValueSender);
boost::shared_ptr<void> ptrEventParamValueMessage = (*ptrEventParams)["message"];
boost::shared_ptr<string> ptrNotifiedMessage = ((boost::static_pointer_cast<string>))(ptrEventParamValueMessage);
}
See Also
Requests.ModeratorMessageRequest
boost::shared_ptr< string > Sfs2X::Core::SFSEvent::OBJECT_MESSAGE
static

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...

The BaseEvent.Params object contains the following parameters.

parameter description
sender (User) the sender of the message
message (ISFSObject) the object data

The following example shows how to handle the event

ptrSmartFox->AddEventListener(SFSEvent::OBJECT_MESSAGE, boost::shared_ptr<EventListenerDelegate> (new EventListenerDelegate(CMyClass::OnObjectMessage, (unsigned long long)this)));
static void OnObjectMessage(unsigned long long ptrContext, boost::shared_ptr<BaseEvent> ptrEvent);
void CMyClass::OnObjectMessage(unsigned long long ptrContext, boost::shared_ptr<BaseEvent> ptrEvent)
{
// Get the pointer to my class
CMyClass* instance = (CMyClass*)ptrContext;
// Get the message parameter of the event
boost::shared_ptr<map<string, boost::shared_ptr<void>>> ptrEventParams = ptrEvent->Params();
boost::shared_ptr<void> ptrEventParamValueMessage = (*ptrEventParams)["message"];
boost::shared_ptr<ISFSObject> ptrNotifiedMessage = ((boost::static_pointer_cast<ISFSObject>))(ptrEventParamValueMessage);
// dumps the data object
virtual boost::shared_ptr<string> dump = obj->GetDump();
}
See Also
Requests.ObjectMessageRequest
boost::shared_ptr< string > Sfs2X::Core::SFSEvent::PING_PONG
static

The SFSEvent.PING_PONG constant defines the value of the type property of the event object for a pingPong event.

The event is fired when measuring the lag between client and server

The properties of the params object contained in the event object have the following values:

PropertyTypeDescription
lagValueintan average of the last 10 lag values, expressed in milliseconds
boost::shared_ptr< string > Sfs2X::Core::SFSEvent::PLAYER_TO_SPECTATOR
static

The Event is fired in response to a failed PlayerToSpectatorRequest

The BaseEvent.Params object contains the following parameters.

parameter description
room (Room) the Room where the player became a spectator
user (User) the User who became a spectator
See Also
Requests.PlayerToSpectatorRequest
boost::shared_ptr< string > Sfs2X::Core::SFSEvent::PLAYER_TO_SPECTATOR_ERROR
static

The Event is fired in response to a failed UnsubscribeRoomGroupRequest

The BaseEvent.Params object contains the following parameters.

parameter description
errorMessage (string) the error message
errorCode (short) the error code
See Also
Requests.PlayerToSpectatorRequest
boost::shared_ptr< string > Sfs2X::Core::SFSEvent::PRIVATE_MESSAGE
static

The Event is fired when a User receives a private message.

The BaseEvent.Params object contains the following parameters.

parameter description
sender (User) the sender of the message
message (String) the message
data (ISFSObject) an object with custom data

The following example shows how to handle the event

ptrSmartFox->AddEventListener(SFSEvent::PRIVATE_MESSAGE, boost::shared_ptr<EventListenerDelegate> (new EventListenerDelegate(CMyClass::OnPrivateMessage, (unsigned long long)this)));
static void OnPrivateMessage(unsigned long long ptrContext, boost::shared_ptr<BaseEvent> ptrEvent);
void CMyClass::OnPrivateMessage(unsigned long long ptrContext, boost::shared_ptr<BaseEvent> ptrEvent)
{
// Get the pointer to my class
CMyClass* instance = (CMyClass*)ptrContext;
// Get the sender parameter of the event
// Get the message parameter of the event
boost::shared_ptr<map<string, boost::shared_ptr<void>>> ptrEventParams = ptrEvent->Params();
boost::shared_ptr<void> ptrEventParamValueSender = (*ptrEventParams)["sender"];
boost::shared_ptr<User> ptrNotifiedUser = ((boost::static_pointer_cast<User>))(ptrEventParamValueSender);
boost::shared_ptr<void> ptrEventParamValueMessage = (*ptrEventParams)["message"];
boost::shared_ptr<string> ptrNotifiedMessage = ((boost::static_pointer_cast<string>))(ptrEventParamValueMessage);
}
See Also
Requests.PrivateMessageRequest
boost::shared_ptr< string > Sfs2X::Core::SFSEvent::PROXIMITY_LIST_UPDATE
static

Dispatched when one more users or one or more MMOItem objects enter/leave the current user's Area of Interest in MMORooms.

This event is fired after an MMORoom is joined and the Sfs2X.Requests.MMO.SetUserPositionRequest request is sent at least one time.

NOTE: this event substitutes the default USER_ENTER_ROOM and USER_EXIT_ROOM events available in regular Rooms.

The BaseEvent.Params object contains the following parameters:

parameter description
room (boost::shared_ptr<Room>) The Room where the event occurred
addedUsers (boost::shared_ptr<vector<boost::shared_ptr<User> > >) A list of User objects representing the users who entered the current user's Area of Interest.
removedUsers (boost::shared_ptr<vector<boost::shared_ptr<User> > >) A list of User objects representing the users who left the current user's Area of Interest.
addedItems (boost::shared_ptr<vector<boost::shared_ptr<IMMOItem> > >) A list of MMOItem objects which entered the current user's Area of Interest.
removedItems (boost::shared_ptr<vector<boost::shared_ptr<IMMOItem> > >) A list of MMOItem objects which left the current user's Area of Interest.

See the Sfs2X.Requests.MMO.SetUserPositionRequest example.

See Also
Sfs2X.Requests.MMO.SetUserPositionRequest, Sfs2X.Entities.MMORoom, Sfs2X.Entities.MMOItem
boost::shared_ptr< string > Sfs2X::Core::SFSEvent::PUBLIC_MESSAGE
static

The Event is fired when a User sends a public message.

Also the User receives this event every time he sends a public message.

The BaseEvent.Params object contains the following parameters.

parameter description
room (Room) the target Room
sender (User) the sender
message (String) the message
data (ISFSObject) an object with custom data

The following example shows how to handle the event

ptrSmartFox->AddEventListener(SFSEvent::PUBLIC_MESSAGE, boost::shared_ptr<EventListenerDelegate> (new EventListenerDelegate(CMyClass::OnPublicMessage, (unsigned long long)this)));
static void OnPublicMessage(unsigned long long ptrContext, boost::shared_ptr<BaseEvent> ptrEvent);
void CMyClass::OnPublicMessage(unsigned long long ptrContext, boost::shared_ptr<BaseEvent> ptrEvent)
{
// Get the pointer to my class
CMyClass* instance = (CMyClass*)ptrContext;
// Get the sender parameter of the event
// Get the message parameter of the event
boost::shared_ptr<map<string, boost::shared_ptr<void>>> ptrEventParams = ptrEvent->Params();
boost::shared_ptr<void> ptrEventParamValueSender = (*ptrEventParams)["sender"];
boost::shared_ptr<User> ptrNotifiedUser = ((boost::static_pointer_cast<User>))(ptrEventParamValueSender);
boost::shared_ptr<void> ptrEventParamValueMessage = (*ptrEventParams)["message"];
boost::shared_ptr<string> ptrNotifiedMessage = ((boost::static_pointer_cast<string>))(ptrEventParamValueMessage);
}
See Also
Requests.PublicMessageRequest
boost::shared_ptr< string > Sfs2X::Core::SFSEvent::ROOM_ADD
static

The 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 BaseEvent.Params object contains the following parameters.

parameter description
room (Room) the room object

The following example shows how to handle the event

ptrSmartFox->AddEventListener(SFSEvent::ROOM_ADD, boost::shared_ptr<EventListenerDelegate> (new EventListenerDelegate(CMyClass::OnRoomAdded, (unsigned long long)this)));
static void OnRoomAdded(unsigned long long ptrContext, boost::shared_ptr<BaseEvent> ptrEvent);
void CMyClass::OnRoomAdded(unsigned long long ptrContext, boost::shared_ptr<BaseEvent> ptrEvent)
{
// A new Room was added
boost::shared_ptr<map<string, boost::shared_ptr<void>>> ptrEventParams = ptrEvent->Params();
boost::shared_ptr<void> ptrEventParamValueRoom = (*ptrEventParams)["room"];
boost::shared_ptr<Room> ptrNotifiedRoom = ((boost::static_pointer_cast<Room>))(ptrEventParamValueRoom);
}
See Also
ROOM_REMOVE, Requests.CreateRoomRequest
boost::shared_ptr< string > Sfs2X::Core::SFSEvent::ROOM_CAPACITY_CHANGE
static

The Event is fired in response to a ChangeRoomCapacityRequest

The BaseEvent.Params object contains the following parameters.

parameter description
room (Room) the Room where the change occurred
See Also
Requests.ChangeRoomCapacityRequest
boost::shared_ptr< string > Sfs2X::Core::SFSEvent::ROOM_CAPACITY_CHANGE_ERROR
static

The Event is fired in response to a failed ChangeRoomCapacityRequest

The BaseEvent.Params object contains the following parameters.

parameter description
errorMessage (string) the error message
errorCode (short) the error code
See Also
Requests.ChangeRoomCapacityRequest
boost::shared_ptr< string > Sfs2X::Core::SFSEvent::ROOM_CREATION_ERROR
static

The Event is dispatched in response to a failed create room request.

The BaseEvent.Params object contains the following parameters.

parameter description
errorMessage (string) the error message
errorCode (short) the error code

The following example shows how to handle the event

ptrSmartFox->AddEventListener(SFSEvent::ROOM_CREATION_ERROR, boost::shared_ptr<EventListenerDelegate> (new EventListenerDelegate(CMyClass::OnRoomCreationError, (unsigned long long)this)));
static void OnRoomCreationError(unsigned long long ptrContext, boost::shared_ptr<BaseEvent> ptrEvent);
void CMyClass::OnRoomCreationError(unsigned long long ptrContext, boost::shared_ptr<BaseEvent> ptrEvent)
{
boost::shared_ptr<map<string, boost::shared_ptr<void>>> ptrEventParams = ptrEvent->Params();
boost::shared_ptr<void> ptrEventParamValueErrorMessage = (*ptrEventParams)["errorMessage"];
boost::shared_ptrvstring> ptrErrorMessage = ((boost::static_pointer_cast<string>))(ptrEventParamValueErrorMessage);
boost::shared_ptr<string> message (new string("Room Creation Error: " + *ptrErrorMessage));
}
See Also
ROOM_ADD, Requests.CreateRoomRequest
boost::shared_ptr< string > Sfs2X::Core::SFSEvent::ROOM_FIND_RESULT
static

The Event is fired in response to a FindRoomsRequest

The BaseEvent.Params object contains the following parameters.

parameter description
rooms (List<Room>) a list of Rooms matching the request criteria. If no Room was found the list will be empty.
See Also
Requests.FindRoomsRequest
boost::shared_ptr< string > Sfs2X::Core::SFSEvent::ROOM_GROUP_SUBSCRIBE
static

The Event is fired in response to a SubscribeRoomGroupRequest

The BaseEvent.Params object contains the following parameters.

parameter description
groupId (String) the name of the group that was subscribed
newRooms (Array) the list of rooms contained in the new group
See Also
Requests.SubscribeRoomGroupRequest
boost::shared_ptr< string > Sfs2X::Core::SFSEvent::ROOM_GROUP_SUBSCRIBE_ERROR
static

The Event is fired in response to a failed SubscribeRoomGroupRequest

The BaseEvent.Params object contains the following parameters.

parameter description
errorMessage (string) the error message
errorCode (short) the error code
See Also
Requests.SubscribeRoomGroupRequest
boost::shared_ptr< string > Sfs2X::Core::SFSEvent::ROOM_GROUP_UNSUBSCRIBE
static

The Event is fired in response to an UnsubscribeRoomGroupRequest

The BaseEvent.Params object contains the following parameters.

parameter description
groupId (String) the name of thr group that was unsubscribed
See Also
Requests.UnsubscribeRoomGroupRequest
boost::shared_ptr< string > Sfs2X::Core::SFSEvent::ROOM_GROUP_UNSUBSCRIBE_ERROR
static

The Event is fired in response to a failed UnsubscribeRoomGroupRequest

The BaseEvent.Params object contains the following parameters.

parameter description
errorMessage (string) the error message
errorCode (short) the error code
See Also
Requests.UnsubscribeRoomGroupRequest
boost::shared_ptr< string > Sfs2X::Core::SFSEvent::ROOM_JOIN
static

The Event is dispatched in response to a JoinRoomRequest.

The BaseEvent.Params object contains the following parameters.

parameter description
room (Room) the joined Room

The following example shows how to handle the event

ptrSmartFox->AddEventListener(SFSEvent::ROOM_JOIN, boost::shared_ptr<EventListenerDelegate> (new EventListenerDelegate(CMyClass::OnJoinRoom, (unsigned long long)this)));
static void OnJoinRoom(unsigned long long ptrContext, boost::shared_ptr<BaseEvent> ptrEvent);
void CMyClass::OnJoinRoom(unsigned long long ptrContext, boost::shared_ptr<BaseEvent> ptrEvent)
{
// Room joined
boost::shared_ptr<map<string, boost::shared_ptr<void>>> ptrEventParams = ptrEvent->Params();
boost::shared_ptr<void> ptrEventParamValueRoom = (*ptrEventParams)["room"];
boost::shared_ptr<Room> ptrNotifiedRoom = ((boost::static_pointer_cast<Room>))(ptrEventParamValueRoom);
}
See Also
ROOM_JOIN_ERROR, Requests.JoinRoomRequest
boost::shared_ptr< string > Sfs2X::Core::SFSEvent::ROOM_JOIN_ERROR
static

The Event is dispatched in response to a failed JoinRoomRequest.

The BaseEvent.Params object contains the following parameters.

parameter description
errorMessage (string) the error message
errorCode (short) the error code

The following example shows how to handle the event

ptrSmartFox->AddEventListener(SFSEvent::ROOM_JOIN_ERROR, boost::shared_ptr<EventListenerDelegate> (new EventListenerDelegate(CMyClass::OnJoinRoomError, (unsigned long long)this)));
static void OnJoinRoomError(unsigned long long ptrContext, boost::shared_ptr<BaseEvent> ptrEvent);
void CMyClass::OnJoinRoomError(unsigned long long ptrContext, boost::shared_ptr<BaseEvent> ptrEvent)
{
boost::shared_ptr<map<string, boost::shared_ptr<void>>> ptrEventParams = ptrEvent->Params();
boost::shared_ptr<void> ptrEventParamValueErrorMessage = (*ptrEventParams)["errorMessage"];
boost::shared_ptr<string> ptrErrorMessage = ((boost::static_pointer_cast<string>))(ptrEventParamValueErrorMessage);
boost::shared_ptr<string> message (new string("Join Room Failure: " + *ptrErrorMessage));
}
See Also
ROOM_JOIN, Requests.JoinRoomRequest
boost::shared_ptr< string > Sfs2X::Core::SFSEvent::ROOM_NAME_CHANGE
static

The Event is fired in response to a ChangeRoomNameRequest

The BaseEvent.Params object contains the following parameters.

parameter description
room (Room) the Room where the change occurred
oldName (String) the old Room name
See Also
Requests.ChangeRoomNameRequest
boost::shared_ptr< string > Sfs2X::Core::SFSEvent::ROOM_NAME_CHANGE_ERROR
static

The Event is fired in response to a failed ChangeRoomNameRequest

The BaseEvent.Params object contains the following parameters.

parameter description
errorMessage (string) the error message
errorCode (short) the error code
See Also
Requests.ChangeRoomNameRequest
boost::shared_ptr< string > Sfs2X::Core::SFSEvent::ROOM_PASSWORD_STATE_CHANGE
static

The 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

The BaseEvent.Params object contains the following parameters.

parameter description
room (Room) the Room where the change occurred
See Also
Requests.ChangeRoomPasswordStateRequest
boost::shared_ptr< string > Sfs2X::Core::SFSEvent::ROOM_PASSWORD_STATE_CHANGE_ERROR
static

The Event is fired in response to a failed ChangeRoomPasswordStateRequest

The BaseEvent.Params object contains the following parameters.

parameter description
errorMessage (string) the error message
errorCode (short) the error code
See Also
Requests.ChangeRoomPasswordStateRequest
boost::shared_ptr< string > Sfs2X::Core::SFSEvent::ROOM_REMOVE
static

The Event is dispatched whenever a Room is removed from the Zone, under any of the Room Groups that the User is listening for.

The BaseEvent.Params object contains the following parameters.

parameter description
room (Room) the room object

The following example shows how to handle the event

ptrSmartFox->AddEventListener(SFSEvent::ROOM_REMOVE, boost::shared_ptr<EventListenerDelegate> (new EventListenerDelegate(CMyClass::OnRoomRemoved, (unsigned long long)this)));
static void OnRoomRemoved(unsigned long long ptrContext, boost::shared_ptr<BaseEvent> ptrEvent);
void CMyClass::OnRoomRemoved(unsigned long long ptrContext, boost::shared_ptr<BaseEvent> ptrEvent)
{
// A Room was removed
boost::shared_ptr<map<string, boost::shared_ptr<void>>> ptrEventParams = ptrEvent->Params();
boost::shared_ptr<void> ptrEventParamValueRoom = (*ptrEventParams)["room"];
boost::shared_ptr<Room> ptrNotifiedRoom = ((boost::static_pointer_cast<Room>))(ptrEventParamValueRoom);
}
See Also
ROOM_ADD
boost::shared_ptr< string > Sfs2X::Core::SFSEvent::ROOM_VARIABLES_UPDATE
static

The Event is fired in response to a SetRoomVariablesRequest

The BaseEvent.Params object contains the following parameters.

parameter description
room (Room) the Room in which the event occurred
changedVars (Array) the list of variable names that where modified or created
See Also
Requests.SetRoomVariablesRequest, Entities.Variables.SFSRoomVariable
boost::shared_ptr< string > Sfs2X::Core::SFSEvent::SFS_SOCKET_ERROR
static

The SFSEvent.SOCKET_ERROR constant defines the value of the type property of the event object for a socketError event.

The event is fired when an unexpected socket error occurs, typically a data error.

The properties of the params object contained in the event object have the following values:

PropertyTypeDescription
errorMessageintthe description of the problem
boost::shared_ptr< string > Sfs2X::Core::SFSEvent::SPECTATOR_TO_PLAYER
static

The Event is fired in response to a successful SpectatorToPlayerRequest

The BaseEvent.Params object contains the following parameters.

parameter description
room (Room) the Room where the spectator became a player
user (User) the User who became a player
playerId (int) the new playerId of the User
See Also
Requests.SpectatorToPlayerRequest
boost::shared_ptr< string > Sfs2X::Core::SFSEvent::SPECTATOR_TO_PLAYER_ERROR
static

The Event is fired in response to a failed SpectatorToPlayerRequest

The BaseEvent.Params object contains the following parameters.

parameter description
errorMessage (string) the error message
errorCode (short) the error code
See Also
Requests.SpectatorToPlayerRequest
boost::shared_ptr< string > Sfs2X::Core::SFSEvent::UDP_INIT
static

The Event notifies the result of the initial UDP handshake.

The handshake is sent in order to establish a channel of communication between client and server.

The BaseEvent.Params object contains the following parameters.

parameter description
success (bool) true if a connection was established, false otherwise.

The following example shows how initialize the UDP channel

ptrSmartFox->AddEventListener(SFSEvent::UPD_INIT, boost::shared_ptr<EventListenerDelegate> (new EventListenerDelegate(CMyClass::OnUDPInit, (unsigned long long)this)));
ptrSmartFox->InitUDP();
static void OnUDPInit(unsigned long long ptrContext, boost::shared_ptr<BaseEvent> ptrEvent);
void CMyClass::OnUDPInit(unsigned long long ptrContext, boost::shared_ptr<BaseEvent> ptrEvent)
{
// Get the pointer to my class
CMyClass* instance = (CMyClass*)ptrContext;
boost::shared_ptr<map<string, boost::shared_ptr<void>>> ptrEventParams = ptrEvent->Params();
boost::shared_ptr<void> ptrEventParamValueSuccess = (*ptrEventParams)["success"];
if ((*((boost::static_pointer_cast<bool>)(ptrEventParamValueSuccess))) == true)
{
// Init OK: Execute an extension call via UDP
boost::shared_ptr<ISFSObject> parameters (new SFSObject());
boost::shared_ptr<IRequest> request (new ExtensionRequest("udpTest", parameters, boost::shared_ptr<Room>(), true));
ptrSmartFox->Send(request);
}
else
{
// Sorry, UDP is not available. Initialization failed
}
}
See Also
SmartFox.InitUDP(string, int)
boost::shared_ptr< string > Sfs2X::Core::SFSEvent::USER_COUNT_CHANGE
static

The 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.

The BaseEvent.Params object contains the following parameters.

parameter description
room (Room) the Room
uCount (int) the new user count
sCount (int) the new spectator count

The following example shows how to handle the event

ptrSmartFox->AddEventListener(SFSEvent::USER_COUNT_CHANGE, boost::shared_ptr<EventListenerDelegate> (new EventListenerDelegate(CMyClass::OnUserCountChange, (unsigned long long)this)));
static void OnUserCountChange(unsigned long long ptrContext, boost::shared_ptr<BaseEvent> ptrEvent);
void CMyClass::OnUserCountChange(unsigned long long ptrContext, boost::shared_ptr<BaseEvent> ptrEvent)
{
// Get the pointer to my class
CMyClass* instance = (CMyClass*)ptrContext;
// Get the room parameter of the event
// Get the users counter parameter of the event
// Get the spectators counter parameter of the event
boost::shared_ptr<map<string, boost::shared_ptr<void>>> ptrEventParams = ptrEvent->Params();
boost::shared_ptr<void> ptrEventParamValueRoom = (*ptrEventParams)["room"];
boost::shared_ptr<Room> ptrNotifiedRoom = ((boost::static_pointer_cast<Room>))(ptrEventParamValueRoom);
boost::shared_ptr<void> ptrEventParamValueUCount = (*ptrEventParams)["uCount"];
int notifiedCounterUsers = *(((boost::static_pointer_cast<int>))(ptrEventParamValueUCount));
boost::shared_ptr<void> ptrEventParamValueSCount = (*ptrEventParams)["sCount"];
int notifiedCounterSpectators = *(((boost::static_pointer_cast<int>))(ptrEventParamValueSCount));
}
boost::shared_ptr< string > Sfs2X::Core::SFSEvent::USER_ENTER_ROOM
static

The Event is fired whenever a User enters one of the Rooms where the current User is joined.

NOTE: if the Room is of type MMORoom, this event is never fired and it is substituted by the PROXIMITY_LIST_UPDATE event.

The BaseEvent.Params object contains the following parameters.

parameter description
user (User) the User object
room (Room) the Room object

The following example shows how to handle the event

ptrSmartFox->AddEventListener(SFSEvent::USER_ENTER_ROOM, boost::shared_ptr<EventListenerDelegate> (new EventListenerDelegate(CMyClass::OnUserEnterRoom, (unsigned long long)this)));
static void OnUserEnterRoom(unsigned long long ptrContext, boost::shared_ptr<BaseEvent> ptrEvent);
void CMyClass::OnUserEnterRoom(unsigned long long ptrContext, boost::shared_ptr<BaseEvent> ptrEvent)
{
// Get the pointer to my class
CMyClass* instance = (CMyClass*)ptrContext;
// Get the user parameter of the event
boost::shared_ptr<map<string, boost::shared_ptr<void>>> ptrEventParams = ptrEvent->Params();
boost::shared_ptr<void> ptrEventParamValueUser = (*ptrEventParams)["user"];
boost::shared_ptr<User> ptrNotifiedUser = ((boost::static_pointer_cast<User>))(ptrEventParamValueUser);
// Get the room parameter of the event
boost::shared_ptr<void> ptrEventParamValueRoom = (*ptrEventParams)["room"];
boost::shared_ptr<Room> ptrNotifiedRoom = ((boost::static_pointer_cast<Room>))(ptrEventParamValueRoom);
}
See Also
USER_EXIT_ROOM, ROOM_JOIN, Requests.JoinRoomRequest
boost::shared_ptr< string > Sfs2X::Core::SFSEvent::USER_EXIT_ROOM
static

The Event is fired whenever a User leaves one of the Rooms where the current User is joined.

NOTE: if the Room is of type MMORoom, this event is never fired and it is substituted by the PROXIMITY_LIST_UPDATE event.

The BaseEvent.Params object contains the following parameters.

parameter description
user (User) the User object
room (Room) the Room object

The following example shows how to handle the event

ptrSmartFox->AddEventListener(SFSEvent::USER_EXIT_ROOM, boost::shared_ptr<EventListenerDelegate> (new EventListenerDelegate(CMyClass::OnUserExitRoom, (unsigned long long)this)));
static void OnUserExitRoom(unsigned long long ptrContext, boost::shared_ptr<BaseEvent> ptrEvent);
void CMyClass::OnUserExitRoom(unsigned long long ptrContext, boost::shared_ptr<BaseEvent> ptrEvent)
{
// Get the pointer to my class
CMyClass* instance = (CMyClass*)ptrContext;
// Get the user parameter of the event
boost::shared_ptr<map<string, boost::shared_ptr<void>>> ptrEventParams = ptrEvent->Params();
boost::shared_ptr<void> ptrEventParamValueUser = (*ptrEventParams)["user"];
boost::shared_ptr<User> ptrNotifiedUser = ((boost::static_pointer_cast<User>))(ptrEventParamValueUser);
// Get the room parameter of the event
boost::shared_ptr<void> ptrEventParamValueRoom = (*ptrEventParams)["room"];
boost::shared_ptr<Room> ptrNotifiedRoom = ((boost::static_pointer_cast<Room>))(ptrEventParamValueRoom);
}
See Also
USER_ENTER_ROOM, ROOM_JOIN, Requests.LeaveRoomRequest
boost::shared_ptr< string > Sfs2X::Core::SFSEvent::USER_FIND_RESULT
static

The Event is fired in response to a FindUsersRequest

The BaseEvent.Params object contains the following parameters.

parameter description
rooms (Array) a list of Users matching the request criteria. If no User was found the list will be empty.
See Also
Requests.FindUsersRequest
boost::shared_ptr< string > Sfs2X::Core::SFSEvent::USER_VARIABLES_UPDATE
static

The Event is fired in response to a SetUserVariablesRequest

The BaseEvent.Params object contains the following parameters.

parameter description
user (User) the User that created or modified the Variables
changedVars (Array) the list of variable names that where modified or created
See Also
Requests.SetUserVariablesRequest, Entities.Variables.SFSUserVariable