SmartFoxServer 2X C++ API
|
This is the main SmartFox Event class. All major system events are found here. More...
#include <SFSEvent.h>
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 > | 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... | |
static boost::shared_ptr< string > | CRYPTO_INIT |
Dispatched in return to the initialization of an encrypted connection. 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... | |
This is the main SmartFox Event class. All major system events are found here.
|
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
|
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.
|
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.
|
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
|
static |
The Event notifies the disconnection from the Server.
When possible the API will also provide a reason for the disconnection:
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
|
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
|
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
|
static |
Dispatched in return to the initialization of an encrypted connection.
This event is fired in response to a call to the SmartFox.InitCrypto() method.
The BaseEvent.Params object contains the following parameters:
Parameter | Description |
---|---|
success | (bool) true if a unique encryption key was successfully retrieved via HTTPS, false if the transaction failed. |
errorMessage | (string) If success is false , provides additional details on the occurred error. |
See the Sfs2X.SmartFox.InitCrypto() example.
|
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 |
|
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) [DEPRECATED - Use room property] The id of the Room which the Extension is attached to (for Room Extensions only). | |
room | (Room) The id of the Room which the Extension is attached to (for Room Extensions only). | (Sfs2X.Entities.Room) An object representing the Room which the Extension is attached to (for Room Extensions only). |
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. |
|
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 |
|
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...) |
|
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 |
|
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
|
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
|
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:
No parameters are passed for this event
The following example shows how to handle a logout event
|
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:
|
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
|
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
|
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:
Property | Type | Description |
---|---|---|
lagValue | int | an average of the last 10 lag values, expressed in milliseconds |
|
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 |
|
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 |
|
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
|
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.
|
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
|
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
|
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 |
|
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 |
|
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
|
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. |
|
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 |
|
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 |
|
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 |
|
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 |
|
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
|
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
|
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 |
|
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 |
|
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 |
|
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 |
|
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
|
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 |
|
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 |
|
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 |
|
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
|
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
|
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
|
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
|
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. |
|
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 |