/** * Creates a new SmartFox instance. * *
The SmartFox class is responsible for connecting the client to a SmartFoxServer instance and for dispatching all asynchronous events.
* Developers always interact with SmartFoxServer through this class.
* For detailed informations please check our website: http://www.smartfoxserver.com.
The SmartFox instance can be configured through a configuration object with the following properties (all optional):
* *Property | Type | Description |
---|---|---|
host | string | The IP address or host name of the SmartFoxServer 2X instance to connect to. |
port | number | The WebSocket port of the SmartFoxServer 2X instance to connect to. |
useSSL | boolean | Use an encrypted SSL connection (WebSocket Secure). |
zone | string | The Zone of the SmartFoxServer 2X instance to join during the login process. |
debug | boolean | Indicates whether the client-server messages console debug should be enabled or not. |
NOTE: in the examples provided throughout the documentation, sfs
always indicates a SmartFox instance.
If set to true
, detailed debugging informations for all the incoming and outgoing messages are provided in the browser's debug console (if available).
* Debugging can be enabled when instantiating the SmartFox class too by means of the configuration object.
The session token is a string sent by the server to the client after the initial handshake.
* It is required as mean of identification when uploading files to the server (see specific documentation).
This manager is used internally by the SmartFoxServer 2X API; the reference returned by this property * gives access to the Rooms list and Groups, allowing interaction with SFSRoom objects.
*/ readonly roomManager: SFSRoomManager; /** * Returns a reference to the User Manager. *This manager is used internally by the SmartFoxServer 2X API; the reference returned by this property * gives access to the users list, allowing interaction with SFSUser objects.
*/ readonly userManager: SFSUserManager; /** * Returns a reference to the Buddy Manager. *This manager is used internally by the SmartFoxServer 2X API; the reference returned by this property * gives access to the buddies list, allowing interaction with Buddy and BuddyVariable objects and access to user properties in the Buddy List system.
*/ readonly buddyManager: SFSBuddyManager; /** * Returns the SFSUser object representing the client itself when connected to a SmartFoxServer 2X instance. * *This object is generated upon successful login only, so it is null
if login was not performed yet.
NOTE: setting the mySelf property manually can disrupt the API functioning.
*/ readonly mySelf: SFSUser; /** * Returns the object representing the last Room joined by the client, if any. * *This property is null
if no Room was joined.
Any request exceeding this size will not be sent. The value is determined by the server configuration.
*/ readonly maxMessageSize: number; /** * [CLUSTER] The identifier of the cluster node which the current SmartFox instance is connected to. * * If the SmartFox instance is not connected to a cluster node, this property is null
.
By default no details are sent and the client type is the generic "JavaScript".
* *NOTE: this method must be called before the connection is started. The length of the two strings combined must be less than 512 characters.
* @param platformId - An identification string for the client, like the browser name for example. * @param version - An additional string to describe the client version, like the browser version for example. */ setClientDetails(platformId: string, version: string): void; /** * Establishes a connection between the client and a SmartFoxServer 2X instance. * *If one or more arguments are missing, the client will use the corresponding settings passed during the SmartFox class instantiation.
* @example *This method should be used for testing and simulations only, otherwise use the
When turned on, the pingPong event type is dispatched continuously, providing the average of the last ten measured lag values. * The lag monitoring is automatically halted when the user logs out of a Zone or gets disconnected.
* *NOTE: the lag monitoring can be enabled after the login has been completed successfully only.
* @param enabled - The lag monitoring status:true
to start the monitoring, false
to stop it.
* @param [interval = 4] - The amount of seconds to wait between each query (recommended 3-4s).
* @param [queueSize = 10] - The amount of values stored temporarily and used to calculate the average lag.
*/
enableLagMonitor(enabled: boolean, interval?: number, queueSize?: number): void;
/**
* Sends a request to the server.
* @example
* NOTE: the same object is returned by the SFSRoomManager.getRoomById() method, accessible through the roomManager property; * this was replicated on the SmartFox class for handy access due to its usually frequent usage.
* @example *undefined
if no SFSRoom object with the passed id exists in the Rooms list.
*/
getRoomById(id: number): SFSRoom;
/**
* Retrieves a SFSRoom object from its name.
*
* NOTE: the same object is returned by the SFSRoomManager.getRoomByName() method, accessible through the roomManager property; * this was replicated on the SmartFox class for handy access due to its usually frequent usage.
* @example *undefined
if no SFSRoom object with the passed name exists in the Rooms list.
*/
getRoomByName(name: string): SFSRoom;
/**
* Returns the list of SFSRoom objects representing the Rooms currently "watched" by the client.
*
* The list contains all the Rooms that are currently joined and all the Rooms belonging to the Room Groups that have been subscribed by the client.
* *NOTE 1: at login time, the client automatically subscribes all the Room Groups specified in the Zone's Default Room Groups setting.
* *NOTE 2: the same list is returned by the SFSRoomManager.getRoomList() method, accessible through the roomManager property; * this was replicated on the SmartFox class for handy access due to its usually frequent usage.
* @returns The list of SFSRoom objects representing the Rooms available on the client. */ getRoomList(): SFSRoom[]; /** * Retrieves the list of Rooms which are part of the specified Room Group. * *NOTE: the same list is returned by the SFSRoomManager.getRoomListFromGroup() method, accessible through the roomManager property; * this was replicated on the SmartFox class for handy access due to its usually frequent usage.
* @param groupId - The name of the Group. * @returns The list of SFSRoom objects belonging to the passed Group. */ getRoomListFromGroup(groupId: string): SFSRoom[]; /** * Returns a list of SFSRoom objects representing the Rooms currently joined by the client. * *NOTE: the same list is returned by the SFSRoomManager.getJoinedRooms() method, accessible through the roomManager property; * this was replicated on the SmartFox class for handy access due to its usually frequent usage.
* @returns The list of SFSRoom objects representing the Rooms joined by the client. */ getJoinedRooms(): SFSRoom[]; /** * Registers an event listener function that will receive notification of an event. * *If you no longer need an event listener, remove it by calling the removeEventListener() method, or memory issues could arise. * In fact event listeners are not automatically removed from memory.
* @example *If you no longer need an event listener, remove it by calling the removeEventListener() method, or memory issues could arise. * In fact event listeners are not automatically removed from memory.
* @example *The constants contained in this class are used to register the event listeners; when an event is dispatched, an object containing event-specific parameters is passed to the listener. * See the documentation below for a description of the parameters available for each event.
* @example *This event is fired in response to a call to the SmartFox.connect() method.
* *Property | Type | Description |
---|---|---|
success | boolean | The connection result: true if a connection was established, false otherwise. |
This event is fired in response to a call to the SmartFox.disconnect() method.
* *Property | Type | Description |
---|---|---|
reason | string | The reason of the disconnection, among those available in the ClientDisconnectionReason class. |
This event is fired in response to the LoginRequest request.
* *Property | Type | Description |
---|---|---|
user | {@link SFSUser} | An object representing the user who performed the login. |
data | {@link SFSObject} | A SFSObject containing custom parameters returned by a custom login system, if any. |
This event is fired in response to the LoginRequest request in case the operation failed.
* *Property | Type | Description |
---|---|---|
errorMessage | string | A message containing the description of the error. |
errorCode | number | The error code. |
See the example provided in the LOGIN constant description.
*/ static readonly LOGIN_ERROR: string; /** * The logout event type, dispatched when the current user performs logs out of the server Zone. * *This event is fired in response to the LogoutRequest request.
* *This event is fired in response to the CreateRoomRequest and CreateSFSGameRequest requests in case the operation is executed successfully.
* *Property | Type | Description |
---|---|---|
room | {@link SFSRoom} | An object representing the Room that was created. |
This event is fired in response to the CreateRoomRequest and CreateSFSGameRequest requests in case the operation failed.
* *Property | Type | Description |
---|---|---|
errorMessage | string | A message containing the description of the error. |
errorCode | number | The error code. |
See the example provided in the ROOM_ADD constant description.
*/ static readonly ROOM_CREATION_ERROR: string; /** * The roomRemove event type, dispatched when a Room belonging to one of the Groups subscribed by the client is removed from the Zone. * *Property | Type | Description |
---|---|---|
room | {@link SFSRoom} | An object representing the Room that was removed. |
This event is fired in response to the JoinRoomRequest and QuickJoinGameRequest requests in case the operation is executed successfully.
* *Property | Type | Description |
---|---|---|
room | {@link SFSRoom} | An object representing the Room that was joined. |
This event is fired in response to the JoinRoomRequest request in case the operation failed.
* *Property | Type | Description |
---|---|---|
errorMessage | string | A message containing the description of the error. |
errorCode | number | The error code. |
See the example provided in the ROOM_JOIN constant description.
*/ static readonly ROOM_JOIN_ERROR: string; /** * The userEnterRoom event type, dispatched when one of the Rooms joined by the current user is entered by another user. * *This event is caused by a JoinRoomRequest request; it might be fired or not depending on the Room configuration defined upon its creation (see the RoomSettings.events setting).
* *NOTE: if the Room is of type MMORoom, this event is never fired and it is substituted by the proximityListUpdate event.
* *Property | Type | Description |
---|---|---|
user | {@link SFSUser} | An object representing the user who joined the Room. |
room | {@link SFSRoom} | An object representing the Room that was joined by a user. |
This event is caused by a LeaveRoomRequest request; it might be fired or not depending on the Room configuration defined upon its creation (see the RoomSettings.events setting).
* *NOTE: if the Room is of type MMORoom, this event is fired when the current user leaves the Room only. * For the other users leaving the Room it is substituted by the proximityListUpdate event.
* *Property | Type | Description |
---|---|---|
user | {@link SFSUser} | An object representing the user who left the Room. |
room | {@link SFSRoom} | An object representing the Room that was left by a user. |
This event is caused by a JoinRoomRequest request or a LeaveRoomRequest request. * The Room must belong to one of the Groups subscribed by the current client; also this event might be fired or not depending on * the Room configuration defined upon its creation (see the RoomSettings.events setting).
* *Property | Type | Description |
---|---|---|
room | {@link SFSRoom} | An object representing the Room in which the users count changed. |
uCount | number | The new users count (players in case of Game Room). |
sCount | number | The new spectators count (Game Room only). |
This event is fired after an MMORoom is joined and the SetUserPositionRequest request is sent at least one time.
* *NOTE: this event substitutes the default userEnterRoom and userExitRoom events available in regular Rooms.
* *Property | Type | Description |
---|---|---|
addedUsers | Array of {@link SFSUser} | A list of SFSUser objects representing the users who entered the current user's Area of Interest. |
removedUsers | Array of {@link SFSUser} | A list of SFSUser objects representing the users who left the current user's Area of Interest. |
addedItems | Array of {@link MMOItem} | A list of MMOItem objects which entered the current user's Area of Interest. |
removedItems | Array of {@link MMOItem} | A list of MMOItem objects which left the current user's Area of Interest. |
This event is fired in response to the PlayerToSpectatorRequest> request if the operation is executed successfully.
* *Property | Type | Description |
---|---|---|
room | {@link SFSRoom} | An object representing the Room in which the player is turned to spectator. |
user | {@link SFSUser} | An object representing the player who was turned to spectator. |
This event is fired in response to the PlayerToSpectatorRequest request in case the operation failed.
* *Property | Type | Description |
---|---|---|
errorMessage | string | A message containing the description of the error. |
errorCode | number | The error code. |
See the example provided in the PLAYER_TO_SPECTATOR constant description.
*/ static readonly PLAYER_TO_SPECTATOR_ERROR: string; /** * The spectatorToPlayer event type, dispatched when a spectator is turned to a player inside a Game Room. * *This event is fired in response to the SpectatorToPlayerRequest> request if the operation is executed successfully.
* *Property | Type | Description |
---|---|---|
room | {@link SFSRoom} | An object representing the Room in which the spectator is turned to player. |
user | {@link SFSUser} | An object representing the spectator who was turned to player. |
playerId | number | The player id of the user. |
This event is fired in response to the SpectatorToPlayerRequest request in case the operation failed.
* *Property | Type | Description |
---|---|---|
errorMessage | string | A message containing the description of the error. |
errorCode | number | The error code. |
See the example provided in the SPECTATOR_TO_PLAYER constant description.
*/ static readonly SPECTATOR_TO_PLAYER_ERROR: string; /** * The roomNameChange event type, dispatched when the name of a Room is changed. * *This event is fired in response to the ChangeRoomNameRequest request if the operation is executed successfully.
* *Property | Type | Description |
---|---|---|
room | {@link SFSRoom} | An object representing the Room which was renamed. |
oldName | string | The previous name of the Room. |
This event is fired in response to the ChangeRoomNameRequest request in case the operation failed.
* *Property | Type | Description |
---|---|---|
errorMessage | string | A message containing the description of the error. |
errorCode | number | The error code. |
See the example provided in the ROOM_NAME_CHANGE constant description.
*/ static readonly ROOM_NAME_CHANGE_ERROR: string; /** * The roomPasswordStateChange event type, dispatched when the password of a Room is set, changed or removed. * *This event is fired in response to the ChangeRoomPasswordStateRequest> request if the operation is executed successfully.
* *Property | Type | Description |
---|---|---|
room | {@link SFSRoom} | An object representing the Room whose password was changed. |
This event is fired in response to the ChangeRoomPasswordStateRequest request in case the operation failed.
* *Property | Type | Description |
---|---|---|
errorMessage | string | A message containing the description of the error. |
errorCode | number | The error code. |
See the example provided in the ROOM_PASSWORD_STATE_CHANGE constant description.
*/ static readonly ROOM_PASSWORD_STATE_CHANGE_ERROR: string; /** * The roomCapacityChange event type, dispatched when the capacity of a Room is changed. * *This event is fired in response to the ChangeRoomCapacityRequest> request if the operation is executed successfully.
* *Property | Type | Description |
---|---|---|
room | {@link SFSRoom} | An object representing the Room whose capacity was changed. |
This event is fired in response to the ChangeRoomCapacityRequest request in case the operation failed.
* *Property | Type | Description |
---|---|---|
errorMessage | string | A message containing the description of the error. |
errorCode | number | The error code. |
See the example provided in the ROOM_CAPACITY_CHANGE constant description.
*/ static readonly ROOM_CAPACITY_CHANGE_ERROR: string; /** * The publicMessage event type, dispatched when a public message is received by the current user. * *This event is caused by a PublicMessageRequest request sent by any user in the target Room, including the current user himself.
* *Property | Type | Description |
---|---|---|
room | {@link SFSRoom} | An object representing the Room at which the message is targeted. |
sender | {@link SFSUser} | An object representing the user who sent the message. |
message | string | The message sent by the user. |
data | {@link SFSObject} | A SFSObject containing custom parameters which might accompany the message. |
This event is caused by a PrivateMessageRequest request sent by any user in the Zone.
* *NOTE: the same event is fired by the sender's client too, so that the user is aware that the message was delivered successfully to the recipient, * and it can be displayed in the private chat area keeping the correct message ordering. In this case there is no default way to know who the message was originally sent to. * As this information can be useful in scenarios where the sender is chatting privately with more than one user at the same time in separate windows or tabs * (and we need to write his own message in the proper one), the data parameter can be used to store, for example, the id of the recipient user.
* *Property | Type | Description |
---|---|---|
sender | {@link SFSUser} | An object representing the user who sent the message. |
message | string | The message sent by the user. |
data | {@link SFSObject} | A SFSObject containing custom parameters which might accompany the message. |
This event is caused by an ObjectMessageRequest request sent by any user in the target Room.
* *Property | Type | Description |
---|---|---|
sender | {@link SFSUser} | An object representing the user who sent the message. |
message | {@link SFSObject} | The content of the message: a SFSObject containing the custom parameters sent by the sender. |
This event can be caused by either the ModeratorMessageRequest, KickUserRequest or * BanUserRequest requests sent by a user with at least moderation privileges. * Also, this event can be caused by a kick/ban action executed through the SmartFoxServer 2X Administration Tool.
* *Property | Type | Description |
---|---|---|
sender | {@link SFSUser} | An object representing the moderator user who sent the message. |
message | string | The message sent by the moderator. |
data | {@link SFSObject} | A SFSObject containing custom parameters which might accompany the message. |
This event is caused by the AdminMessageRequest request sent by a user with administration privileges.
* *Property | Type | Description |
---|---|---|
sender | {@link SFSUser} | An object representing the administrator user who sent the message. |
message | string | The message sent by the administrator. |
data | {@link SFSObject} | A SFSObject containing custom parameters which might accompany the message. |
Data is usually sent by the server to one or more clients in response to an ExtensionRequest request, but not necessarily.
* *Property | Type | Description |
---|---|---|
cmd | string | The name of the command which identifies an action that should be executed by the client. * If this event is fired in response to a request sent by the client, it is a common practice * to use the same command name passed to the request also in the response. |
params | {@link SFSObject} | A SFSObject containing custom data sent by the Extension. |
room | {@link SFSRoom} | An object representing the Room which the Extension is attached to (for Room Extensions only). |
This event is caused by the SetRoomVariablesRequest request. The request could have been sent by a user in the same Room of the current user or, * in case of a global Room Variable, by a user in a Room belonging to one of the Groups subscribed by the current client.
* *Property | Type | Description |
---|---|---|
room | {@link SFSRoom} | An object representing the Room where the Room Variable update occurred. |
changedVars | Array of string | The list of names of the Room Variables that were changed (or created for the first time). |
This event is caused by the SetUserVariablesRequest request sent by a user in one of the Rooms joined by the current user.
* *Property | Type | Description |
---|---|---|
user | {@link SFSUser} | An object representing the user who updated his own User Variables. |
changedVars | Array of string | The list of names of the User Variables that were changed (or created for the first time). |
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.
* *Property | Type | Description |
---|---|---|
room | {@link MMORoom} | The MMORoom where the MMOItem whose Variables have been updated is located. |
mmoItem | {@link MMOItem} | The MMOItem whose variables have been updated. |
changedVars | Array of string | The list of names of the MMOItem Variables that were changed (or created for the first time). |
This event is fired in response to the SubscribeRoomGroupRequest> request if the operation is executed successfully.
* *Property | Type | Description |
---|---|---|
groupId | string | The name of the Group that was subscribed. |
newRooms | Array of {@link SFSRoom} | A list of SFSRoom objects representing the Rooms belonging to the subscribed Group. |
This event is fired in response to the SubscribeRoomGroupRequest request in case the operation failed.
* *Property | Type | Description |
---|---|---|
errorMessage | string | A message containing the description of the error. |
errorCode | number | The error code. |
See the example provided in the ROOM_GROUP_SUBSCRIBE constant description.
*/ static readonly ROOM_GROUP_SUBSCRIBE_ERROR: string; /** * The roomGroupUnsubscribe event type, dispatched when a Group is unsubscribed by the current user. * *This event is fired in response to the UnsubscribeRoomGroupRequest request if the operation is executed successfully.
* *Property | Type | Description |
---|---|---|
groupId | string | The name of the Group that was unsubscribed. |
This event is fired in response to the UnsubscribeRoomGroupRequest request in case the operation failed.
* *Property | Type | Description |
---|---|---|
errorMessage | string | A message containing the description of the error. |
errorCode | number | The error code. |
See the example provided in the ROOM_GROUP_UNSUBSCRIBE constant description.
*/ static readonly ROOM_GROUP_UNSUBSCRIBE_ERROR: string; /** * The roomFindResult event type, dispatched when a Rooms search is completed. * *This event is fired in response to the FindRoomsRequest request to return the search result.
* *Property | Type | Description |
---|---|---|
rooms | Array of {@link SFSRoom} | A list of SFSRoom objects representing the Rooms matching the search criteria. If no Room is found, the list is empty. |
This event is fired in response to the FindUsersRequest request to return the search result.
* *Property | Type | Description |
---|---|---|
users | Array of {@link SFSUser} | A list of SFSUser objects representing the users matching the search criteria. If no user is found, the list is empty. |
This event is caused by the InviteUsersRequest and CreateSFSGameRequest requests; the user is supposed to reply using the InvitationReplyRequest request.
* *Property | Type | Description |
---|---|---|
invitation | {@link SFSInvitation} | An object representing the invitation received by the current user. |
This event is caused by the InvitationReplyRequest request sent by the invitee.
* *Property | Type | Description |
---|---|---|
invitee | {@link SFSUser} | An object representing the user who replied to the invitation. |
reply | number | The answer to the invitation among those available as constants in the InvitationReply class. |
data | {@link SFSObject} | A SFSObject containing custom parameters, for example a message describing the reason of refusal. |
See the example provided in the INVITATION constant description.
*/ static readonly INVITATION_REPLY: string; /** * The invitationReplyError event type, dispatched when an error occurs while the current user is sending a reply to an invitation he received. * *This event is fired in response to the InvitationReplyRequest request in case the operation failed.
* *Property | Type | Description |
---|---|---|
errorMessage | string | A message containing the description of the error. |
errorCode | number | The error code. |
See the example provided in the INVITATION constant description.
*/ static readonly INVITATION_REPLY_ERROR: string; /** * The pingPong event type, dispatched when a new lag value measurement is available. * *This event is fired when the automatic lag monitoring is turned on by passing true
to the enableLagMonitor() method.
Property | Type | Description |
---|---|---|
lagValue | number | The average of the last ten measured lag values, expressed in milliseconds. |
Property | Type | Description |
---|---|---|
errorMessage | string | The description of the error. |
The constants contained in this class are used to register the event listeners; when an event is dispatched, an object containing event-specific parameters is passed to the listener. * See the documentation below for a description of the parameters available for each event.
* @example *This event is fired in response to the InitBuddyListRequest request in case the operation is executed successfully.
* *After the Buddy List system initialization, the user returns to his previous custom state (if any - see SFSBuddyManager.getMyState() method). * His online/offline state, his nickname and his persistent Buddy Variables are all loaded and broadcast in the system. * In particular, the online state (see SFSBuddyManager.getMyOnlineState() method) determines if the user will appear online or not to other users who have him in their buddies list.
* *Property | Type | Description |
---|---|---|
buddyList | Array of {@link SFSBuddy} | A list of SFSBuddy objects representing all the buddies in the current user's buddy list. |
myVariables | Array of {@link SFSBuddyVariable} | A list of all the Buddy Variables associated with the current user. |
This event is fired in response to the AddBuddyRequest request in case the operation is executed successfully.
* *Property | Type | Description |
---|---|---|
buddy | {@link SFSBuddy} | The SFSBuddy object corresponding to the buddy that was added. |
This event is fired in response to the RemoveBuddyRequest request in case the operation is executed successfully.
* *Property | Type | Description |
---|---|---|
buddy | {@link SFSBuddy} | The SFSBuddy object corresponding to the buddy that was removed. |
This event is fired in response to the BlockBuddyRequest request in case the operation is executed successfully.
* *Property | Type | Description |
---|---|---|
buddy | {@link SFSBuddy} | The SFSBuddy object corresponding to the buddy that was blocked/unblocked. |
For example, this event is fired in response to the AddBuddyRequest request, the BlockBuddyRequest, etc.
* *Property | Type | Description |
---|---|---|
errorMessage | string | A message containing the description of the error. |
errorCode | number | The error code. |
See the example provided in the BUDDY_ADD constant description.
*/ static readonly BUDDY_ERROR: string; /** * The buddyOnlineStateChange event type, dispatched when a buddy in the current user's buddy list changes his online state in the Buddy List system. * *This event is fired in response to the GoOnlineRequest request.
* *NOTE: this event is dispatched to those who have the user as a buddy, but also to the user himself.
* As in this case the value of the buddy parameter is null
(because the user is not buddy to himself of course),
* the isItMe parameter should be used to check if the current user is the one who changed his own online state.
Property | Type | Description |
---|---|---|
buddy | {@link SFSBuddy} | The SFSBuddy object representing the buddy who changed his own online state. If the isItMe parameter is true , the value of this parameter is null (because a user is not buddy to himself). |
isItMe | boolean | true if the online state was changed by the current user himself (in this case this event is a sort of state change confirmation). |
This event is fired in response to the SetBuddyVariablesRequest request.
* *NOTE: this event is dispatched to those who have the user as a buddy, but also to the user himself.
* As in this case the value of the buddy parameter is null
(because the user is not buddy to himself of course) and
* the isItMe parameter should be used to check if the current user is the one who updated his own Buddy Variables.
Property | Type | Description |
---|---|---|
buddy | {@link SFSBuddy} | The SFSBuddy object representing the buddy who updated his own Buddy Variables. If the isItMe parameter is true , the value of this parameter is null (because a user is not buddy to himself). |
isItMe | boolean | true if the Buddy Variables were updated by the current user himself (in this case this event is a sort of update confirmation). |
changedVars | Array of string | The list of names of the Buddy Variables that were changed (or created for the first time). |
This event is fired in response to the BuddyMessageRequest request.
* *NOTE: the same event is fired by the sender's client too, so that the user is aware that the message was delivered successfully to the recipient,
* and it can be displayed in the chat area keeping the correct message ordering. As in this case the value of the buddy parameter is null
* (because, being the sender, the user is not buddy to himself of course), there is no default way to know who the message was originally sent to.
* As this information can be useful in scenarios where the sender is chatting with more than one buddy at the same time in separate windows or tabs
* (and we need to write his own message in the proper one), the data parameter can be used to store, for example, the id of the recipient buddy.
Property | Type | Description |
---|---|---|
buddy | {@link SFSBuddy} | The SFSBuddy object representing the message sender. If the isItMe parameter is true , the value of this parameter is null (because a user is not buddy to himself). |
isItMe | boolean | true if the message sender is the current user himself (in this case this event is a sort of message delivery confirmation). |
message | string | The message text. |
data | {@link SFSObject} | A SFSObject containing additional custom parameters (e.g. the message color, an emoticon id, etc). |
The constants contained in this class are used to register the event listeners; when an event is dispatched, an object containing event-specific parameters is passed to the listener. * See the documentation below for a description of the parameters available for each event.
* @example *This event is fired when the Lobby signals that the client should join a given Game Node, in response to a ClusterJoinOrCreateRequest request or when an invitation to join an existing game on a Game Node is accepted by the invited user.
* *Property | Type | Description |
---|---|---|
configObj | object | The pre-populated client configuration object to start a new connection towards the designated Game Node. |
userName | string | The user name to access the Game Node. |
password | string | A temporary and unique password to access the Game Node. |
For example, this event can be fired in response to the ClusterJoinOrCreateRequest request.
* *The event does not provide further details as the Load Balancer simply queries the available servers and if none is found matching the contextual criteria, the cluster request cannot be completed.
* @example *null
value.
*/
static readonly NULL: number;
/**
* A boolean value.
*/
static readonly BOOL: number;
/**
* A byte (8 bit) value.
*/
static readonly BYTE: number;
/**
* A short integer (16 bit) value.
*/
static readonly SHORT: number;
/**
* An integer (32 bit) value.
*/
static readonly INT: number;
/**
* A long integer value.
*
* IMPORTANT: in JavaScript, long integer numbers are limited to {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number/MAX_SAFE_INTEGER Number.MAX_SAFE_INTEGER} (positive and negative, inclusive).
* This is inconsistent with the max and min Long values available in Java, which are down to -2^63
and up to 2^63 - 1
.
* So if you are developing your server side Extension in Java, make sure you take this limitation into account when dealing with integers.
IMPORTANT: in JavaScript, long integer numbers are limited to {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number/MAX_SAFE_INTEGER Number.MAX_SAFE_INTEGER} (positive and negative, inclusive).
* This is inconsistent with the max and min Long values available in Java, which are down to -2^63
and up to 2^63 - 1
.
* So if you are developing your server side Extension in Java, make sure you take this limitation into account when dealing with integers.
This is a sort of specialized map object that can contain any type of data. The advantage of using the SFSObject class
* (for example when sending an ExtensionRequest request) is that you can fine tune the way your data is transmitted over the network.
* For instance, a number like 100
can be transmitted as a normal integer (which takes 32 bits), but also a short (16 bit) or even a byte (8 bit).
SFSObject supports many primitive data types and related arrays of primitives; see the SFSDataType class.
* *NOTE: UTF-8/multi-byte strings are not supported in key names. In other words you should restrict key names to standard ASCII characters. It is also recommended to keep key names very short to save bandwidth.
*/ export class SFSObject { /** * Retrieves a list of all the keys contained in this object. * @returns The list of all the keys in this object. */ getKeysArray(): string[]; /** * Returns the number of elements in this object. * @returns The number of elements in this object. */ size(): number; /** * Indicates whether this object contains a mapping for the specified key. * @param key - The key whose presence in this object is to be checked. * @returnstrue
if this object contains a mapping for the passed key.
*/
containsKey(key: string): boolean;
/**
* Returns the value assigned to the specified key.
*
* If the typeId parameter is passed, this method also executes a type check, to make sure the requested value has the expected type. * In particular this is used by the other specialized get...() methods.
* @param key - The key whose associated value is to be returned. * @param [typeId = null] - The identifier of the expected value's type; must be one of the constants set in the SFSDataType class. *null
is returned if no value is associated with the passed key.
*/
get(key: string, typeId?: number): any;
/**
* Indicates if the value mapped by the passed key is of type SFSDataType.NULL.
* @param key - The key to be checked.
* @returns true
if the value mapped by the passed key is of type SFSDataType.NULL.
*/
isNull(key: string): boolean;
/**
* Returns the boolean value corresponding to the passed key.
* @param key - The key whose associated value is to be returned.
* @returns The value assigned to the specified key.
*/
getBool(key: string): boolean;
/**
* Returns the byte value corresponding to the passed key.
* @param key - The key whose associated value is to be returned.
* @returns The value assigned to the specified key.
*/
getByte(key: string): number;
/**
* Returns the short integer corresponding to the passed key.
* @param key - The key whose associated value is to be returned.
* @returns The value assigned to the specified key.
*/
getShort(key: string): number;
/**
* Returns the integer corresponding to the passed key.
* @param key - The key whose associated value is to be returned.
* @returns The value assigned to the specified key.
*/
getInt(key: string): number;
/**
* Returns the long integer corresponding to the passed key.
*
* IMPORTANT: in JavaScript, long integer numbers are limited to {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number/MAX_SAFE_INTEGER Number.MAX_SAFE_INTEGER} (positive and negative, inclusive).
* This is inconsistent with the max and min Long values available in Java, which are down to -2^63
and up to 2^63 - 1
.
* In case a number greater than {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number/MAX_SAFE_INTEGER Number.MAX_SAFE_INTEGER} is returned, this could differ from the actual value set on the server side (a warning will be logged on the client).
IMPORTANT: in JavaScript, long integer numbers are limited to {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number/MAX_SAFE_INTEGER Number.MAX_SAFE_INTEGER} (positive and negative, inclusive).
* This is inconsistent with the max and min Long values available in Java, which are down to -2^63
and up to 2^63 - 1
.
This is a shortcut for the put() method.
* @param key - The key to which the specified value has to be assigned. */ putNull(key: string): void; /** * Assigns a boolean value to the passed key. * *This is a shortcut for the put() method.
* @param key - The key to which the specified value has to be assigned. * @param value - The value to be assigned to the passed key. */ putBool(key: string, value: boolean): void; /** * Assigns a number to the passed key as a byte (8 bit). * *This is a shortcut for the put() method.
* @param key - The key to which the specified value has to be assigned. * @param value - The value to be assigned to the passed key. */ putByte(key: string, value: number): void; /** * Assigns a number to the passed key as a short integer (16 bit). * *This is a shortcut for the put() method.
* @param key - The key to which the specified value has to be assigned. * @param value - The value to be assigned to the passed key. */ putShort(key: string, value: number): void; /** * Assigns a number to the passed key as an integer (32 bit). * *This is a shortcut for the put() method.
* @param key - The key to which the specified value has to be assigned. * @param value - The value to be assigned to the passed key. */ putInt(key: string, value: number): void; /** * Assigns a number to the passed key as a long integer. * *IMPORTANT: in JavaScript, long integer numbers are limited to {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number/MAX_SAFE_INTEGER Number.MAX_SAFE_INTEGER} (positive and negative, inclusive).
* This is inconsistent with the max and min Long values available in Java, which are down to -2^63
and up to 2^63 - 1
.
* So if you are developing your server side Extension in Java, make sure you take this limitation into account when dealing with integers.
This is a shortcut for the put() method.
* @param key - The key to which the specified value has to be assigned. * @param value - The value to be assigned to the passed key. */ putLong(key: string, value: number): void; /** * Assigns a number to the passed key as a floating point value (32 bit). * *This is a shortcut for the put() method.
* @param key - The key to which the specified value has to be assigned. * @param value - The value to be assigned to the passed key. */ putFloat(key: string, value: number): void; /** * Assigns a number to the passed key as a double precision value (64 bit). * *This is a shortcut for the put() method.
* @param key - The key to which the specified value has to be assigned. * @param value - The value to be assigned to the passed key. */ putDouble(key: string, value: number): void; /** * Assigns a UTF-8 string to the passed key (max length: 32 KBytes). * *This is a shortcut for the put() method.
* @param key - The key to which the specified value has to be assigned. * @param value - The value to be assigned to the passed key. */ putUtfString(key: string, value: string): void; /** * Assigns a UTF-8 text to the passed key (max length: 2 GBytes). * *This is a shortcut for the put() method.
* @param key - The key to which the specified value has to be assigned. * @param value - The value to be assigned to the passed key. */ putText(key: string, value: string): void; /** * Assigns an array of booleans to the passed key. * *This is a shortcut for the put() method.
* @param key - The key to which the specified array has to be assigned. * @param array - The array to be assigned to the passed key. */ putBoolArray(key: string, array: boolean[]): void; /** * Assigns a byte array to the passed key. * *This is a shortcut for the put() method.
* @param key - The key to which the specified byte array has to be assigned. * @param array - The byte array to be assigned to the passed key. */ putByteArray(key: string, array: Uint8Array): void; /** * Assigns an array of numbers to the passed key as short integers. * *This is a shortcut for the put() method.
* @param key - The key to which the specified array has to be assigned. * @param array - The array to be assigned to the passed key. */ putShortArray(key: string, array: number[]): void; /** * Assigns an array of numbers to the passed key as integers. * *This is a shortcut for the put() method.
* @param key - The key to which the specified array has to be assigned. * @param array - The array to be assigned to the passed key. */ putIntArray(key: string, array: number[]): void; /** * Assigns an array of numbers to the passed key as long integers. * *This is a shortcut for the put() method.
* *Read important note in the put() method description.
* @param key - The key to which the specified array has to be assigned. * @param array - The array to be assigned to the passed key. */ putLongArray(key: string, array: number[]): void; /** * Assigns an array of numbers to the passed key as floating point values. * *This is a shortcut for the put() method.
* @param key - The key to which the specified array has to be assigned. * @param array - The array to be assigned to the passed key. */ putFloatArray(key: string, array: number[]): void; /** * Assigns an array of numbers to the passed key as double precision values. * *This is a shortcut for the put() method.
* @param key - The key to which the specified array has to be assigned. * @param array - The array to be assigned to the passed key. */ putDoubleArray(key: string, array: number[]): void; /** * Assigns an array of UTF-8 strings to the passed key. * *This is a shortcut for the put() method.
* @param key - The key to which the specified array has to be assigned. * @param array - The array to be assigned to the passed key. */ putUtfStringArray(key: string, array: string[]): void; /** * Assigns a nested SFSArray to the passed key. * *This is a shortcut for the put() method.
* @param key - The key to which the specified value has to be assigned. * @param value - The SFSArray to be assigned to the passed key. */ putSFSArray(key: string, value: SFSArray): void; /** * Assigns a nested SFSObject to the passed key. * *This is a shortcut for the put() method.
* @param key - The key to which the specified value has to be assigned. * @param value - The SFSObject to be assigned to the passed key. */ putSFSObject(key: string, value: SFSObject): void; /** * Provides a formatted string representing this object. * *The returned string can be logged or traced in the console for debugging purposes.
* @param [format = true] - Iftrue
, the output is formatted in a human-readable way.
* @returns The string representation of this object.
*/
getDump(format?: boolean): string;
/**
* Provides a detailed hexadecimal representation of this object.
*
* The returned string can be logged or traced in the console for debugging purposes.
* @returns The hexadecimal string representation of this object. */ getHexDump(): string; } /** * Creates a new SFSArray instance. * *This is a sort of specialized list object that can contain any type of data. The advantage of using the SFSArray class
* (for example as a nested object inside a SFSObject object) is that you can fine tune the way your data is transmitted over the network.
* For instance, when transmitting a list of numbers between 0
and 100
, those values can be treated as normal integers (which take 32 bits each), but also as shorts (16 bit) or even as bytes (8 bit).
SFSArray supports many primitive data types and related arrays of primitives; see the SFSDataType class.
*/ export class SFSArray { /** * Indicates the number of elements in this array. * @returns The number of elements in this array. */ size(): number; /** * Indicates whether this SFSArray contains the specified object or not. * *NOTE: this method doesn't support checking the presence of a nested SFSObject or SFSArray.
* @param object - The object whose presence in this array is to be tested. * @returnstrue
if the specified object is present in the SFSArray.
*/
contains(object: any): boolean;
/**
* Returns the element at the specified index.
*
* If the typeId parameter is passed, this method also executes a type check, to make sure the requested value has the expected type. * In particular this is used by the other specialized get...() methods.
* @param index - The position of the element to return. * @param [typeId = null] - The identifier of the expected value's type; must be one of the constants set in the SFSDataType class. *true
if the element at the specified index is of type SFSDataType.NULL.
*/
isNull(index: number): boolean;
/**
* Returns the boolean value at the specified index.
* @param index - The position of the element to return.
* @returns The element of this array at the specified index.
*/
getBool(index: number): boolean;
/**
* Returns the byte value at the specified index.
* @param index - The position of the element to return.
* @returns The element of this array at the specified index.
*/
getByte(index: number): number;
/**
* Returns the short integer at the specified index.
* @param index - The position of the element to return.
* @returns The element of this array at the specified index.
*/
getShort(index: number): number;
/**
* Returns the integer at the specified index.
* @param index - The position of the element to return.
* @returns The element of this array at the specified index.
*/
getInt(index: number): number;
/**
* Returns the long at the specified index.
*
* IMPORTANT: in JavaScript, long integer numbers are limited to {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number/MAX_SAFE_INTEGER Number.MAX_SAFE_INTEGER} (positive and negative, inclusive).
* This is inconsistent with the max and min Long values available in Java, which are down to -2^63
and up to 2^63 - 1
.
* In case a number greater than {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number/MAX_SAFE_INTEGER Number.MAX_SAFE_INTEGER} is returned, this could differ from the actual value set on the server side (a warning will be logged on the client).
IMPORTANT: in JavaScript, long integer numbers are limited to {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number/MAX_SAFE_INTEGER Number.MAX_SAFE_INTEGER} (positive and negative, inclusive).
* This is inconsistent with the max and min Long values available in Java, which are down to -2^63
and up to 2^63 - 1
.
This is a shortcut for the add() method.
*/ addNull(): void; /** * Appends a boolean value to the end of this array. * *This is a shortcut for the add() method.
* @param value - The value to be appended to this array. */ addBool(value: boolean): void; /** * Appends a number to the end of this array as a byte (8 bit). * *This is a shortcut for the add() method.
* @param value - The value to be appended to this array. */ addByte(value: number): void; /** * Appends a number to the end of this array as a short integer (16 bit). * *This is a shortcut for the add() method.
* @param value - The value to be appended to this array. */ addShort(value: number): void; /** * Appends a number to the end of this array as an integer (32 bit). * *This is a shortcut for the add() method.
* @param value - The value to be appended to this array. */ addInt(value: number): void; /** * Appends a number to the end of this array as a long integer. * *IMPORTANT: in JavaScript, long integer numbers are limited to {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number/MAX_SAFE_INTEGER Number.MAX_SAFE_INTEGER} (positive and negative, inclusive).
* This is inconsistent with the max and min Long values available in Java, which are down to -2^63
and up to 2^63 - 1
.
* So if you are developing your server side Extension in Java, make sure you take this limitation into account when dealing with integers.
This is a shortcut for the add() method.
* @param value - The value to be appended to this array. */ addLong(value: number): void; /** * Appends a number to the end of this array as a floating point value (32 bit). * *This is a shortcut for the add() method.
* @param value - The value to be appended to this array. */ addFloat(value: number): void; /** * Appends a number to the end of this array as a double precision value (64 bit). * *This is a shortcut for the add() method.
* @param value - The value to be appended to this array. */ addDouble(value: number): void; /** * Appends a UTF-8 string to the end of this array (max length: 32 KBytes). * *This is a shortcut for the add() method.
* @param value - The value to be appended to this array. */ addUtfString(value: string): void; /** * Appends a UTF-8 string to the end of this array (max length: 2 GBytes). * *This is a shortcut for the add() method.
* @param value - The value to be appended to this array. */ addText(value: string): void; /** * Appends an array of booleans to the end of this array. * *This is a shortcut for the add() method.
* @param array - The array to be appended to this array. */ addBoolArray(array: boolean[]): void; /** * Appends a byte array to the end of this array. * *This is a shortcut for the add() method.
* @param array - The byte array to be appended to this array. */ addByteArray(array: Uint8Array): void; /** * Appends an array of numbers to the end of this array as short integers. * *This is a shortcut for the add() method.
* @param array - The array to be appended to this array. */ addShortArray(array: number[]): void; /** * Appends an array of numbers to the end of this array as integers. * *This is a shortcut for the add() method.
* @param array - The array to be appended to this array. */ addIntArray(array: number[]): void; /** * Appends an array of numbers to the end of this array as long integers. * *This is a shortcut for the add() method.
* *Read important note in the add() method description.
* @param array - The array to be appended to this array. */ addLongArray(array: number[]): void; /** * Appends an array of numbers to the end of this array as floating point values. * *This is a shortcut for the add() method.
* @param array - The array to be appended to this array. */ addFloatArray(array: number[]): void; /** * Appends an array of numbers to the end of this array as double precision values. * *This is a shortcut for the add() method.
* @param array - The array to be appended to this array. */ addDoubleArray(array: number[]): void; /** * Appends an array of UTF-8 strings to the end of this array. * *This is a shortcut for the add() method.
* @param array - The array to be appended to this array. */ addUtfStringArray(array: string[]): void; /** * Appends a nested SFSArray to the end of this array. * *This is a shortcut for the add() method.
* @param value - The SFSArray to be appended to this array. */ addSFSArray(value: SFSArray): void; /** * Appends a nested SFSObject to the end of this array. * *This is a shortcut for the add() method.
* @param value - The SFSObject to be appended to this array. */ addSFSObject(value: SFSObject): void; /** * Provides a formatted string representing this array. * *The returned string can be logged or traced in the console for debugging purposes.
* @param [format = true] - Iftrue
, the output is formatted in a human-readable way.
* @returns The string representation of this array.
*/
getDump(format?: boolean): string;
/**
* Provides a detailed hexadecimal representation of this array.
*
* The returned string can be logged or traced in the console for debugging purposes.
* @returns The hexadecimal string representation of this array. */ getHexDump(): string; } /** * Creates a new Vec3D instance. * *The position along the Z axis is optional for 2D environments.
* *The useFloats parameter can be used to force the API send the coordinates as floating point values
* when setting the user position (see the SetUserPositionRequest request) or creating an MMORoom.
* This must be set accordingly to the server side setting of the MMORoom and consistently through the client.
An invitation is sent through the InviteUsersRequest request and it is received as an invitation event. * Clients can reply to an invitation using the InvitationReplyRequest request.
*/ export class SFSInvitation { /** * Indicates the id of the invitation. * It is generated by the server when the invitation is sent. */ readonly id: number; /** * Returns the SFSUser object corresponding to the user who sent the invitation. */ readonly inviter: SFSUser; /** * Returns the SFSUser object corresponding to the user who received the invitation. */ readonly invitee: SFSUser; /** * Returns the number of seconds available to the invitee to reply to the invitation, after which the invitation expires. */ readonly secondsForAnswer: number; /** * Returns a SFSObject containing a custom set of parameters. * It usually stores invitation details, like a message to the invitee and any other relevant data. */ readonly params: SFSObject; } /** * The possible replies to an invitation. */ export class InvitationReply { constructor(); /** * Invitation is accepted. */ static readonly ACCEPT: number; /** * Invitation is refused. */ static readonly REFUSE: number; /** * Invitation expired. */ static readonly EXPIRED: number; } /** * Developers never istantiate the Matcher class: this is done internally by the SmartFoxServer 2X API. */ export class Matcher { /** * Returns the type id of this matcher. */ readonly type: number; /** * Returns the condition symbol of this matcher. */ readonly symbol: string; } /** * Developers never istantiate the BoolMatch class: only use its static properties. */ export class BoolMatch extends Matcher { /** * An instance of BoolMatch representing the following condition: bool1 == bool2. */ static readonly EQUALS: BoolMatch; /** * An instance of BoolMatch representing the following condition: bool1 != bool2. */ static readonly NOT_EQUALS: BoolMatch; /** * Returns the type id of this matcher. */ readonly type: number; /** * Returns the condition symbol of this matcher. */ readonly symbol: string; } /** * Developers never istantiate the NumberMatch class: only use its static properties. */ export class NumberMatch extends Matcher { /** * An instance of NumberMatch representing the following condition: number1 == number2. */ static readonly EQUALS: NumberMatch; /** * An instance of NumberMatch representing the following condition: number1 != number2. */ static readonly NOT_EQUALS: NumberMatch; /** * An instance of NumberMatch representing the following condition: number1 > number2. */ static readonly GREATER_THAN: NumberMatch; /** * An instance of NumberMatch representing the following condition: number1 >= number2. */ static readonly GREATER_THAN_OR_EQUAL_TO: NumberMatch; /** * An instance of NumberMatch representing the following condition: number1 < number2. */ static readonly LESS_THAN: NumberMatch; /** * An instance of NumberMatch representing the following condition: number1 <= number2. */ static readonly LESS_THAN_OR_EQUAL_TO: NumberMatch; /** * Returns the type id of this matcher. */ readonly type: number; /** * Returns the condition symbol of this matcher. */ readonly symbol: string; } /** * Developers never istantiate the StringMatch class: only use its static properties. */ export class StringMatch extends Matcher { /** * An instance of StringMatch representing the following condition: string1 == string2. */ static readonly EQUALS: StringMatch; /** * An instance of StringMatch representing the following condition: string1 != string2. */ static readonly NOT_EQUALS: StringMatch; /** * An instance of StringMatch representing the following condition: string1.indexOf(string2) != -1. */ static readonly CONTAINS: StringMatch; /** * An instance of StringMatch representing the following condition: string1 starts with characters contained in string2. */ static readonly STARTS_WITH: StringMatch; /** * An instance of StringMatch representing the following condition: string1 ends with characters contained in string2. */ static readonly ENDS_WITH: StringMatch; /** * Returns the type id of this matcher. */ readonly type: number; /** * Returns the condition symbol of this matcher. */ readonly symbol: string; } /** * Creates a new MatchExpression instance. * *Matching expression are used to compare custom variables or predefined properties when searching for users or Rooms. They are built like "if" statements in any common programming language. * They work like queries in a database and can be used to search for Rooms or users using custom criteria: in fact a matching expression can compare predefined * properties of the Room and user entities (see the RoomProperties and UserProperties classes), but also custom Room or User Variables.
* *These expressions are easy to create and concatenate, and they can be used for many different filtering operations within the SmartFoxServer 2X framework, * for example to invite players to join a game (see the CreateSFSGameRequest request description), to look for specific Rooms * or users (see the FindRoomsRequest and FindUsersRequest requests descriptions), etc.
* *Additionally:
*Depending what the matching expression is used for (searching a user or a Room), this can be * the name of a User Variable or a Room Variable, or it can be one of the constants contained in the UserProperties or RoomProperties classes, representing some of the predefined properties of the user and Room entities respectively.
*/ readonly varName: string; /** * Returns the matching criteria used during values comparison among those provided by the BoolMatch, NumberMatch and StringMatch classes. */ readonly condition: Matcher; /** * Returns the value against which the variable or property corresponding to varName is compared. */ readonly value: any; /** * In case of concatenated expressions, returns the current logical operator. */ readonly logicOp: LogicOperator; /** * Returns the next matching expression concatenated to the current one, if existing. */ readonly next: MatchExpression; /** * Concatenates the current expression with a new one using the logical AND operator. * @param varName - Name of the additional variable or property to match. * @param condition - The additional matching condition among those provided by the BoolMatch, NumberMatch and StringMatch classes. * @param value - The value to compare against the additional variable or property during the matching. * @returns A new MatchExpression resulting from the concatenation of the current expression with a new one generated from the specified parameters. */ and(varName: string, condition: Matcher, value: boolean | number | string): MatchExpression; /** * Concatenates the current expression with a new one using the logical OR operator. * @param varName - Name of the additional variable or property to match. * @param condition - The additional matching condition among those provided by the BoolMatch, NumberMatch and StringMatch classes. * @param value - The value to compare against the additional variable or property during the matching. * @returns A new MatchExpression resulting from the concatenation of the current expression with a new one generated from the specified parameters. */ or(varName: string, condition: Matcher, value: boolean | number | string): MatchExpression; /** * Checks if the current matching expression is concatenated to another one through a logical operator. * @returnstrue
if the current matching expression is concatenated to another one.
*/
hasNext(): boolean;
/**
* Moves the iterator cursor to the first matching expression in the chain.
* @returns The MatchExpression object at the top of the chain of matching expressions.
*/
rewind(): MatchExpression;
/**
* Returns a string representation of the matching expression.
* @returns The string representation of the MatchExpression object.
*/
toString(): string;
}
/**
* Developers never istantiate the LogicOperator class: only use its static properties.
*/
export class LogicOperator {
/**
* Returns the id of the current LogicOperator instance.
* It can be the string "AND" or "OR".
*/
readonly id: string;
/**
* An instance of LogicOperator representing the AND logical operator.
*/
static readonly AND: LogicOperator;
/**
* An instance of LogicOperator representing the OR logical operator.
*/
static readonly OR: LogicOperator;
}
/**
* Developers never istantiate the RoomProperties class: only use its static properties.
*/
export class RoomProperties {
constructor();
/**
* The Room name.
* Requires a StringMatch instance to be used for values comparison.
*/ static readonly NAME: string; /** * The name of the Group to which the Room belongs. *Requires a StringMatch instance to be used for values comparison.
*/ static readonly GROUP_ID: string; /** * The maximum number of users allowed in the Room (players in Game Rooms). *Requires a NumberMatch instance to be used for values comparison.
*/ static readonly MAX_USERS: string; /** * The maximum number of spectators allowed in the Room (Game Rooms only). *Requires a NumberMatch instance to be used for values comparison.
*/ static readonly MAX_SPECTATORS: string; /** * The Room users count (players in Game Rooms). *Requires a NumberMatch instance to be used for values comparison.
*/ static readonly USER_COUNT: string; /** * The Room spectators count (Game Rooms only). *Requires a NumberMatch instance to be used for values comparison.
*/ static readonly SPECTATOR_COUNT: string; /** * The Room is a Game Room. *Requires a BoolMatch instance to be used for values comparison.
*/ static readonly IS_GAME: string; /** * The Room is private. *Requires a BoolMatch instance to be used for values comparison.
*/ static readonly IS_PRIVATE: string; /** * The Room has at least one free player slot. *Requires a BoolMatch instance to be used for values comparison.
*/ static readonly HAS_FREE_PLAYER_SLOTS: string; /** * The Room is an SFSGame on the server-side. *Requires a BoolMatch instance to be used for values comparison.
*/ static readonly IS_TYPE_SFSGAME: string; /** * The Room is an MMORoom on the server-side. *Requires a BoolMatch instance to be used for values comparison.
*/ static readonly IS_TYPE_MMO: string; /** * The Room is of default type on the server-side. *Requires a BoolMatch instance to be used for values comparison.
*/ static readonly IS_TYPE_DEFAULT: string; } /** * Developers never istantiate the UserProperties class: only use its static properties. */ export class UserProperties { constructor(); /** * The Room name. *Requires a StringMatch instance to be used for values comparison.
*/ static readonly NAME: string; /** * The user is a player in a Game Room. *Requires a BoolMatch instance to be used for values comparison.
*/ static readonly IS_PLAYER: string; /** * The user is a spectator in a Game Room. *Requires a BoolMatch instance to be used for values comparison.
*/ static readonly IS_SPECTATOR: string; /** * The user is a Non-Player Character (NPC). *Requires a BoolMatch instance to be used for values comparison.
*/ static readonly IS_NPC: string; /** * The user privilege id. *Requires a NumberMatch instance to be used for values comparison.
*/ static readonly PRIVILEGE_ID: string; /** * The user joined at least one Room. *Requires a BoolMatch instance to be used for values comparison.
*/ static readonly IS_IN_ANY_ROOM: string; } /** * Developers never istantiate the SFSBuddy class: this is done internally by the SmartFoxServer 2X API. * *A buddy is marked out by the following characteristics:
*null
is returned.
*
* The list of available custom states is returned by the SFSBuddyManager.getBuddyStates() method.
*/ readonly state: string; /** * Returns the nickname of this buddy. * If the nickname is not set,null
is returned.
*/
readonly nickName: string;
/**
* Returns a string that contains the buddy id and name.
* @returns The string representation of the SFSBuddy object.
*/
toString(): string;
/**
* Retrieves a Buddy Variable from its name.
* @param varName - The name of the Buddy Variable to be retrieved.
* @returns The object representing the Buddy Variable, or undefined
if no Buddy Variable with the passed name is associated to this buddy.
*/
getVariable(varName: string): SFSBuddyVariable;
/**
* Indicates whether this user has the specified Buddy Variable set or not.
* @param varName - The name of the Buddy Variable whose existance must be checked.
* @returns true
if a Buddy Variable with the passed name is set for this buddy.
*/
containsVariable(varName: string): boolean;
/**
* Retrieves all the Buddy Variables of this user.
* @returns The list of SFSBuddyVariable objects associated to the buddy.
*/
getVariables(): SFSBuddyVariable[];
/**
* Retrieves the list of persistent Buddy Variables for this buddy.
* @returns A list of SFSBuddyVariable objects corresponding to the buddy's persistent Buddy Variables.
*/
getOfflineVariables(): SFSBuddyVariable[];
/**
* Retrieves the list of non-persistent Buddy Variables for this buddy.
* @returns A list of SFSBuddyVariable objects corresponding to the buddy's non-persistent Buddy Variables.
*/
getOnlineVariables(): SFSBuddyVariable[];
}
/**
* Developers never istantiate the MMOItem class: this is done internally by the SmartFoxServer 2X API.
*
* MMOItems can be used to represent bonuses, triggers, bullets, etc, or any other non-player entity that will be handled using the MMORoom's rules of visibility. * This means that whenever one or more MMOItems fall within the Area of Interest of a user, their presence will be notified to that user by means of the * proximityListUpdate event.
*MMOItems are identified by a unique ID and can have one or more MMOItem Variables associated to store custom data.
*/ export class MMOItem { /** * Indicates the id of this item. * The id is unique and it is generated by the server when the MMOItem is created. */ readonly id: number; /** * Returns the entry point of this item in the current user's AoI. * *The returned coordinates are those that the item had when its presence in the current user's Area of Interest was last notified by a proximityListUpdate event. * This field is populated only if the MMORoom in which the item exists is configured to receive such data.
*/ readonly aoiEntryPoint: Vec3D; /** * Returns a string that contains the item id. * @returns The string representation of the MMOItem object. */ toString(): string; /** * Retrieves an MMOItem Variable from its name. * @param varName - The name of the MMOItem Variable to be retrieved. * @returns The MMOItemVariable object, orundefined
if no MMOItem Variable with the passed name is associated to this item.
*/
getVariable(varName: string): MMOItemVariable;
/**
* Indicates whether this item has the specified MMOItem Variable set or not.
* @param varName - The name of the MMOItem Variable whose existance must be checked.
* @returns true
if an MMOItem Variable with the passed name is set for this item.
*/
containsVariable(varName: string): boolean;
/**
* Retrieves all the MMOItem Variables of this item.
* @returns The list of MMOItemVariable objects associated to this item.
*/
getVariables(): MMOItemVariable[];
}
/**
* Developers never istantiate the SFSRoom class: this is done internally by the SmartFoxServer 2X API.
*
* The Room is the basic structure used to group users connected to SmartFoxServer 2X. * The client API is not aware of all the Rooms existing on the server side, * but only of those that are joined by the user and those in the Room Groups that have been subscribed. * Subscribing to one or more Groups allows the client to listen to Room events in specific "areas" of the Zone, * without having to retrieve and keep synchronized the details of all available Rooms, thus reducing * the traffic between the client and the server considerably.
* *The list of available Rooms is created after a successful login and it is kept updated continuously by the server.
*/ export class SFSRoom { /** * Defines a generic utility object that can be used to store custom Room data. * The values added to this object are for client-side use only and are never transmitted to the server or to the other clients. */ properties: any; /** * Indicates the id of this Room. * The id is unique and it is generated by the server when the Room is created. */ readonly id: number; /** * Indicates the name of this Room. * Two Rooms in the same Zone can't have the same name. * If allowed, the name can be changed through the ChangeRoomNameRequest request. */ readonly name: string; /** * Returns the Room Group name. * Each Group is identified by a unique string (its name or id) and it represents a different "container" for Rooms. * *Room Groups enable developers to organize Rooms under different types or categories and let clients select only those Groups they are interested in, in order to receive their events only. * This is done via the SubscribeRoomGroupRequest and UnsubscribeRoomGroupRequest requests.
*/ readonly groupId: string; /** * Indicates whether this is a Game Room or not. */ readonly isGame: boolean; /** * Indicates whether this Room is hidden or not. * This is a utility flag that can be used by developers to hide certain Rooms from the interface of their application. */ readonly isHidden: boolean; /** * Indicates whether the client joined this Room or not. * Use the JoinRoomRequest request to join a new Room. */ readonly isJoined: boolean; /** * Indicates whether this Room requires a password to be joined or not. * This flag depends on the Room's password set when the Room is created or by means of the ChangeRoomPasswordStateRequest request. */ readonly isPasswordProtected: boolean; /** * Returns the maximum number of users allowed in this Room. * In case of Game Rooms, this is the maximum number of players. * If allowed, the maxUsers value can be changed through the ChangeRoomCapacityRequest request. */ readonly maxUsers: number; /** * Returns the maximum number of spectators allowed in this Room (Game Rooms only). * If allowed, the maxSpectators value can be changed through the ChangeRoomCapacityRequest request. */ readonly maxSpectators: number; /** * Returns the current number of users in this Room. * In case of Game Rooms, this is the number of players. */ readonly userCount: number; /** * Returns the current number of spectators in this Room (Game Rooms only). */ readonly spectatorCount: number; /** * Returns the maximum amount of users, including spectators, that can be contained in this Room. */ readonly capacity: number; /** * Returns a string that contains the Room id, name and id of the Group to which it belongs. * @returns The string representation of the SFSRoom object. */ toString(): string; /** * Retrieves a SFSUser object from its name property. * @param name - The name of the user to be found. * @returns An object representing the user, orundefined
if no user with the passed name exists in this Room.
*/
getUserByName(name: string): SFSUser;
/**
* Retrieves a SFSUser object from its id property.
* @param id - The id of the user to be found.
* @returns An object representing the user, or undefined
if no user with the passed id exists in this Room.
*/
getUserById(id: number): SFSUser;
/**
* Indicates whether the specified user is currently inside this Room or not.
* @param user - The SFSUser object representing the user whose presence in this Room must be checked.
* @returns true
if the user is inside this Room; false
otherwise.
*/
containsUser(user: SFSUser): boolean;
/**
* Retrieves the list of SFSUser objects representing all the users currently inside this Room.
* @returns The list of SFSUser objects representing the users who joined the Room.
*/
getUserList(): SFSUser[];
/**
* Retrieves the list of SFSUser objects representing the players currently inside this Room (Game Rooms only).
* @returns The list of SFSUser objects representing the users who joined the Room as players.
*/
getPlayerList(): SFSUser[];
/**
* Retrieves the list of SFSUser objects representing the spectators currently inside this Room (Game Rooms only).
* @returns The list of SFSUser objects representing the users who joined the Room as spectators.
*/
getSpectatorList(): SFSUser[];
/**
* Retrieves a Room Variable from its name.
* @param varName - The name of the Room Variable to be retrieved.
* @returns The object representing the Room Variable, or undefined
if no Room Variable with the passed name exists in this Room.
*/
getVariable(varName: string): SFSRoomVariable;
/**
* Indicates whether this Room has the specified Room Variable set or not.
* @param varName - The name of the Room Variable whose existance in this Room must be checked.
* @returns true
if a Room Variable with the passed name exists in this Room.
*/
containsVariable(varName: string): boolean;
/**
* Retrieves all the Room Variables of this Room.
* @returns The list of SFSRoomVariable objects associated with this Room.
*/
getVariables(): SFSRoomVariable[];
/**
* Retrieves a reference to the Room Manager which manages this Room.
* @returns The Room Manager to which this Room is associated.
*/
getRoomManager(): SFSRoomManager;
}
/**
* Developers never istantiate the MMORoom class: this is done internally by the SmartFoxServer 2X API.
*
* The MMORoom is ideal for huge virtual worlds and MMO games because it works with proximity lists instead of "regular" users lists. * This allows thousands of users to interact with each other based on their Area of Interest (AoI). The AoI represents a range around the user * that is affected by server and user events, outside which no other events are received.
* *The size of the AoI is set at Room creation time and it is the same for all users who joined it. * Supposing that the MMORoom hosts a 3D virtual world, setting an AoI of (x=100, y=100, z=40) for the Room tells the server to transmit updates and broadcast * events to and from those users that fall within the AoI range around the current user; this means the area within +/- 100 units on the X axis, +/- 100 units on the Y axis * and +/- 40 units on the Z axis.
* *As the user moves around in the virtual environment, he can update his position in the corresponding MMORoom and thus continuously receive events * about other users (and items - see below) entering and leaving his AoI. * The player will be able to update his position via the SetUserPositionRequest request and receive updates on his current proximity list by means of the * proximityListUpdate event.
* *Finally, MMORooms can also host any number of "MMOItems" which represent dynamic non-player objects that users can interact with. * They are handled by the MMORoom using the same rules of visibility described before.
*/ export class MMORoom { /** * Returns the default Area of Interest (AoI) of this MMORoom. */ readonly defaultAOI: Vec3D; /** * Returns the lower coordinates limit of the virtual environment represented by the MMORoom along the X,Y,Z axes. * Ifnull
is returned, no limits were set at Room creation time.
*/
readonly lowerMapLimit: Vec3D;
/**
* Returns the higher coordinates limit of the virtual environment represented by the MMORoom along the X,Y,Z axes.
* If null
is returned, no limits were set at Room creation time.
*/
readonly higherMapLimit: Vec3D;
/**
* Retrieves an MMOItem object from its id property.
*
* The item is available to the current user if it falls within his Area of Interest only.
* @param id - The id of the item to be retrieved.
* @returns An MMOItem object, or undefined
if the item with the passed id is not in proximity of the current user.
*/
getMMOItem(id: number): MMOItem;
/**
* Retrieves all MMOItem object in the MMORoom that fall within the current user's Area of Interest.
* @returns A list of MMOItem objects, or an empty list if no item is in proximity of the current user.
*/
getMMOItems(): MMOItem[];
}
/**
* Developers never istantiate the SFSUser class: this is done internally by the SmartFoxServer 2X API.
*
* The SFSUser object represents a client logged in SmartFoxServer 2X. * The client API is not aware of all the clients (users) connected to the server, * but only of those that are in the same Rooms joined by the current client; this reduces the traffic between the client and the server considerably. * In order to interact with other users the client should join other Rooms or use the Buddy List system to keep track of and interact with friends.
*/ export class SFSUser { /** * Defines a generic utility object that can be used to store custom user data. * The values added to this object are for client-side use only and are never transmitted to the server or to the other clients. */ properties: any; /** * Indicates the id of this user. * The id is unique and it is generated by the server when the user logs in. */ readonly id: number; /** * Indicates the name of this user. * Two users in the same Zone can't have the same name. */ readonly name: string; /** * Indicates if this SFSUser object represents the current client. */ readonly isItMe: boolean; /** * Returns the id which identifies the privilege level of this user. * Privileges are assigned to the user by the server when the user logs in. */ readonly privilegeId: number; /** * Returns the entry point of this user in the current user's AoI. * *The returned coordinates are those that the user had when his presence in the current user's Area of Interest was last notified by a proximityListUpdate event. * This field is populated only if the user joined a Room of type MMORoom and this is configured to receive such data from the server.
*/ readonly aoiEntryPoint: Vec3D; /** * Indicates whether this user logged in as a guest or not. * Guest users have the privilegeId property set to UserPrivileges.GUEST. */ readonly isGuest: boolean; /** * Indicates whether this user logged in as a standard user or not. * Standard users have the privilegeId property set to UserPrivileges.STANDARD. */ readonly isStandardUser: boolean; /** * Indicates whether this user logged in as a moderator or not. * Moderator users have the privilegeId property set to UserPrivileges.MODERATOR. */ readonly isModerator: boolean; /** * Indicates whether this user logged in as an administrator or not. * Administrator users have the privilegeId property set to UserPrivileges.ADMINISTRATOR. */ readonly isAdmin: boolean; /** * Indicates whether this user is a player (playerId greater than0
) in the last joined Room or not.
* Non-Game Rooms always return false
.
*
* If the user is inside multiple Game Rooms at the same time, use the isPlayerInRoom() method.
*/ readonly isPlayer: boolean; /** * Indicates whether this user is a spectator (playerId lower than0
) in the last joined Room or not.
* Non-Game Rooms always return false
.
*
* If the user is inside multiple Game Rooms at the same time, use the isSpectatorInRoom() method.
*/ readonly isSpectator: boolean; /** * Returns a string that contains the user id, name and a boolean indicating if the SFSUser object represents the current client. * @returns The string representation of the SFSUser object. */ toString(): string; /** * Indicates whether this user joined the passed Room or not. * @param room - The SFSRoom object representing the Room where to check the user presence. * @returnstrue
if this user is inside the passed Room.
*/
isJoinedInRoom(room: SFSRoom): boolean;
/**
* Returns the playerId value of this user in the passed Room.
* See the playerId property description for more informations.
* @param room - The SFSRoom object representing the Room to retrieve the player id from.
* @returns The playerId of this user in the passed Room.
*/
getPlayerId(room: SFSRoom): number;
/**
* Indicates whether this user is a player (playerId greater than 0
) in the passed Room or not.
* Non-Game Rooms always return false
.
*
* If a user can join one Game Rooms at a time only, use the isPlayer property.
* @param room - The SFSRoom object representing the Room where to check if this user is a player. * @returnstrue
if this user is a player in the passed Room.
*/
isPlayerInRoom(room: SFSRoom): boolean;
/**
* Indicates whether this user is a spectator (playerId lower than 0
) in the passed Room or not.
* Non-Game Rooms always return false
.
*
* If a user can join one Game Rooms at a time only, use the isSpectator property.
* @param room - The SFSRoom object representing the Room where to check if this user is a spectator. * @returnstrue
if this user is a spectator in the passed Room.
*/
isSpectatorInRoom(room: SFSRoom): boolean;
/**
* Retrieves a User Variable from its name.
* @param varName - The name of the User Variable to be retrieved.
* @returns The object representing the User Variable, or undefined
if no User Variable with the passed name is associated with this user.
*/
getVariable(varName: string): SFSUserVariable;
/**
* Indicates whether this user has the specified User Variable set or not.
* @param varName - The name of the User Variable whose existance must be checked.
* @returns true
if a User Variable with the passed name is set for this user.
*/
containsVariable(varName: string): boolean;
/**
* Retrieves all the User Variables of this user.
* @returns The list of SFSUserVariable objects associated with the user.
*/
getVariables(): SFSUserVariable[];
/**
* Returns a reference to the User Manager which manages this user.
* @returns The User Manager to which this user is associated.
*/
getUserManager(): SFSUserManager;
}
/**
* Developers never istantiate the UserPrivileges class: only use its static properties.
*
* Values contained in this class (or custom-defined ones) are assigned to the SFSUser.privilegeId property whenever a user logs in.
* Read the SmartFoxServer 2X documentation for more informations about privilege profiles and their permissions.
This variable is persistent, which means that the online/offline state is preserved upon disconnection.
*/ static readonly BV_ONLINE: string; /** * The Buddy Variable with this name stores the custom state of the user in a buddy list. *This variable is persistent, which means that the custom state is preserved upon disconnection.
*/ static readonly BV_STATE: string; /** * The Buddy Variable with this name stores the optional nickname of the user in a buddy list. *This variable is persistent, which means that the nickname is preserved upon disconnection.
*/ static readonly BV_NICKNAME: string; } /** * Creates a new SFSBuddyVariable instance. * *A SFSBuddyVariable is a custom value attached to a SFSBuddy object in a Buddy List that gets automatically synchronized between client and server on every change.
* *Buddy Variables work with the same principle of the User and Room Variables. The only difference is the logic by which they get propagated to other users. * While Room and User Variables are usually broadcast to all clients in the same Room, Buddy Variables updates are sent to all users who have the owner of the Buddy Variable in their Buddy Lists.
* *Buddy Variables are particularly useful to store custom user data that must be "visible" to the buddies only, such as a profile, a ranking, a status message, etc.
* Buddy Variables can be set by means of the SetBuddyVariablesRequest request; they support the following data types (also nested):
* boolean, number, string, SFSObject, SFSArray. A Buddy Variable can also be null
.
There is also a special convention that allows Buddy Variables to be set as "offline".
* Offline Buddy Variables are persistent values which are made available to all users who have the owner in their Buddy List, whether that buddy is online or not.
* In order to make a Buddy Variable persistent, its name should start with a dollar sign ($
).
* This conventional character is contained in the OFFLINE_PREFIX constant.
null
.
* @param [type = -1] - The type id of the Buddy Variable among those available in the VariableType class. Usually it is not necessary to pass this parameter, as the type is auto-detected from the value.
*/
export class SFSBuddyVariable extends BaseVariable {
constructor(name: string, value: boolean | number | string | SFSObject | SFSArray, type?: number);
/**
* The prefix to be added to a Buddy Variable name to make it persistent.
* A persistent Buddy Variable is made available to all users who have the owner in their Buddy List, whether that Buddy is online or not.
*/
static readonly OFFLINE_PREFIX: string;
/**
* Indicates whether the Buddy Variable is persistent or not.
*
* By convention any Buddy Variable whose name starts with the dollar sign ($
) will be regarded as persistent and stored locally by the server.
* Persistent Buddy Variables are also referred to as "offline variables" because they are available to all users
* who have the owner in their Buddy List, whether that Buddy is online or not.
null
, boolean
, int
, double
, string
, SFSObject
, SFSArray
.
*/
readonly type: string;
/**
* Indicates if the Variable is null
.
*/
readonly isNull: boolean;
}
/**
* Developers never istantiate the MMOItemVariable class: even if MMOItem Variables behave exactly like User Variables and support the same data types, they can be created, updated and deleted on the server side only.
*
* An MMOItemVariable is a custom value attached to an MMOItem object that gets automatically synchronized between client and server on every change, * provided that the MMOItem is inside the Area of Interest of the current user in a MMORoom.
* @param name - The name of the MMOItem Variable. * @param value - The value of the MMOItem Variable; it can also benull
.
* @param [type = -1] - The type id of the MMOItem Variable among those available in the VariableType class. Usually it is not necessary to pass this parameter, as the type is auto-detected from the value.
*/
export class MMOItemVariable extends BaseVariable {
constructor(name: string, value: boolean | number | string | SFSObject | SFSArray, type?: number);
/**
* Returns a string that contains the MMOItem Variable name, type and value.
* @returns The string representation of the MMOItemVariable object.
*/
toString(): string;
/**
* Indicates the name of this variable.
*/
readonly name: string;
/**
* Returns the value of this variable.
*/
readonly value: any;
/**
* Indicates the type of this Variable.
* Possibly returned strings are: null
, boolean
, int
, double
, string
, SFSObject
, SFSArray
.
*/
readonly type: string;
/**
* Indicates if the Variable is null
.
*/
readonly isNull: boolean;
}
/**
* Developers never istantiate the ReservedRoomVariables class: only use its static properties.
*/
export class ReservedRoomVariables {
constructor();
/**
* The Room Variable with this name keeps track of the state (started or stopped) of a game created with the CreateSFSGameRequest request.
*/
static readonly RV_GAME_STARTED: string;
}
/**
* Creates a new SFSRoomVariable instance.
*
* A SFSRoomVariable is a custom value attached to a SFSRoom object that gets automatically synchronized between client and server on every change.
* *Room Variables are particularly useful to store custom Room data such as a game status and other Room-level informations.
* They can be set by means of the SetRoomVariablesRequest request; they support the following data types (also nested):
* boolean, number, string, SFSObject, SFSArray. A Room Variable can also be null
.
Room Variables also support a number of specific flags:
*null
.
* @param [type = -1] - The type id of the Room Variable among those available in the VariableType class. Usually it is not necessary to pass this parameter, as the type is auto-detected from the value.
*/
export class SFSRoomVariable extends BaseVariable {
constructor(name: string, value: boolean | number | string | SFSObject | SFSArray, type?: number);
/**
* Indicates whether this Room Variable is private or not.
* A private Room Variable is visible to all users in the same Room, but it can be modified only by its owner (the user that created it).
*
* NOTE: setting the isPrivate property manually on an existing Room Variable returned by the API has no effect on the server and can disrupt the API functioning. * This flag can be set after the Room Variable object is created using the constructor only.
*/ isPrivate: boolean; /** * Indicates whether this Room Variable is persistent or not. * A persistent Room Variable continues to exist in the Room after the user who created it has left it and until he disconnects. * *NOTE: setting the isPersistent property manually on an existing Room Variable returned by the API has no effect on the server and can disrupt the API functioning. * This flag can be set after the Room Variable object is created using the constructor only.
*/ isPersistent: boolean; /** * Returns a string that contains the Room Variable name, type, value and isPrivate flag. * @returns The string representation of the SFSRoomVariable object. */ toString(): string; /** * Indicates the name of this variable. */ readonly name: string; /** * Returns the value of this variable. */ readonly value: any; /** * Indicates the type of this Variable. * Possibly returned strings are:null
, boolean
, int
, double
, string
, SFSObject
, SFSArray
.
*/
readonly type: string;
/**
* Indicates if the Variable is null
.
*/
readonly isNull: boolean;
}
/**
* Creates a new SFSUserVariable instance.
*
* A SFSUserVariable is a custom value attached to a SFSUser object that gets automatically synchronized between client and server on every change.
* *User Variables are particularly useful to store custom user data that must be "visible" to the other users, such as a profile, a score, a status message, etc.
* User Variables can be set by means of the SetUserVariablesRequest request; they support the following data types (also nested):
* boolean, number, string, SFSObject, SFSArray. A User Variable can also be null
.
null
.
* @param [type = -1] - The type id of the User Variable among those available in the VariableType class. Usually it is not necessary to pass this parameter, as the type is auto-detected from the value.
*/
export class SFSUserVariable extends BaseVariable {
constructor(name: string, value: boolean | number | string | SFSObject | SFSArray, type?: number);
/**
* Indicates whether this User Variable is private or not.
* A private User Variable is visible only to its owner; any changes made to the variable will be transmitted to the owner only.
*
* NOTE: setting the isPrivate property manually on an existing User Variable returned by the API has no effect on the server and can disrupt the API functioning. * This flag can be set after the User Variable object is created using the constructor only.
*/ isPrivate: boolean; /** * Returns a string that contains the User Variable name, type, value and isPrivate flag. * @returns The string representation of the SFSUserVariable object. */ toString(): string; /** * Indicates the name of this variable. */ readonly name: string; /** * Returns the value of this variable. */ readonly value: any; /** * Indicates the type of this Variable. * Possibly returned strings are:null
, boolean
, int
, double
, string
, SFSObject
, SFSArray
.
*/
readonly type: string;
/**
* Indicates if the Variable is null
.
*/
readonly isNull: boolean;
}
/**
* The valid types for User, Room, Buddy and MMOItem Variables to be passed to the respective constructors.
*/
export class VariableType {
constructor();
/**
* The Variable is null
.
*/
static readonly NULL: number;
/**
* The type of the Variable is boolean.
*/
static readonly BOOLEAN: number;
/**
* The type of the Variable is number (specifically an integer).
*/
static readonly INT: number;
/**
* The type of the Variable is number (specifically a double).
*/
static readonly DOUBLE: number;
/**
* The type of the Variable is string.
*/
static readonly STRING: number;
/**
* The type of the Variable is SFSObject.
*/
static readonly SFSOBJECT: number;
/**
* The type of the Variable is SFSArray.
*/
static readonly SFSARRAY: number;
}
/**
* Developers never istantiate the BaseVariable class: always use its child classes.
*/
export class BaseVariable {
/**
* Indicates the name of this variable.
*/
readonly name: string;
/**
* Returns the value of this variable.
*/
readonly value: any;
/**
* Indicates the type of this Variable.
* Possibly returned strings are: null
, boolean
, int
, double
, string
, SFSObject
, SFSArray
.
*/
readonly type: string;
/**
* Indicates if the Variable is null
.
*/
readonly isNull: boolean;
}
/**
* Developers never istantiate the SFSBuddyManager class: this is done internally by the SmartFoxServer 2X API; get a reference to it using the SmartFox.buddyManager property.
*
* This class keeps track of all the user's buddies, their state and their Buddy Variables. * It also provides utility methods to set the user's properties when he is part of the buddies list of other users.
* *IMPORTANT: no Buddy List related operations are allowed until the system is initialized using the InitBuddyListRequest request.
*/ export class SFSBuddyManager { /** * Indicates whether the client's Buddy List system is initialized or not. * If not, an InitBuddyListRequest request should be sent to the server in order to retrieve the persistent Buddy List data. */ readonly isInited: boolean; /** * Indicates whether a buddy exists in user's buddy list or not. * @param name - The name of the buddy whose presence in the buddy list is to be checked. * @returnstrue
if the specified buddy exists in the buddy list.
*/
containsBuddy(name: string): boolean;
/**
* Retrieves a SFSBuddy object from its id property.
* @param id - The id of the buddy to be retrieved.
* @returns The SFSBuddy object representing the buddy, or undefined
if no buddy with the passed id exists in the buddy list.
*/
getBuddyById(id: number): SFSBuddy;
/**
* Retrieves a SFSBuddy object from its name property.
* @param name - The name of the buddy to be retrieved.
* @returns The SFSBuddy object representing the buddy, or undefined
if no buddy with the passed name exists in the buddy list.
*/
getBuddyByName(name: string): SFSBuddy;
/**
* Retrieves a SFSBuddy object using its nickName property.
* @param nickName - The nickname of the buddy to be found.
* @returns The SFSBuddy object representing the buddy, or undefined
if no buddy with the passed nickname exists in the buddies list.
*/
getBuddyByNickName(nickName: string): SFSBuddy;
/**
* Returns a list of SFSBuddy objects representing all the offline buddies in the user's buddy list.
* @returns A list of SFSBuddy objects representing the offline buddies.
*/
getOfflineBuddies(): SFSBuddy[];
/**
* Returns a list of SFSBuddy objects representing all the online buddies in the user's buddy list.
* @returns A list of SFSBuddy objects representing the online buddies.
*/
getOnlineBuddies(): SFSBuddy[];
/**
* Returns a list of SFSBuddy objects representing all the buddies in the user's buddy list.
* @returns A list of SFSBuddy objects representing all the buddies.
*/
getBuddyList(): SFSBuddy[];
/**
* Retrieves a Buddy Variable set for the current user from its name.
* @param varName - The name of the Buddy Variable to be retrieved.
* @returns The SFSBuddyVariable object representing the Buddy Variable, or undefined
if no Buddy Variable with the passed name is associated to the current user.
*/
getMyVariable(varName: string): SFSBuddyVariable;
/**
* Returns all the Buddy Variables set for the current user.
* @returns A list of SFSBuddyVariable objects representing all the Buddy Variables set for the user.
*/
getMyVariables(): SFSBuddyVariable[];
/**
* Returns the current user's online/offline state.
*
* If true
, the user appears to be online in the buddy list of other users who have him as a buddy.
* The online state of a user in a buddy list is handled by means of a reserved Buddy Variable (see ReservedBuddyVariables class);
* it can be changed using the dedicated GoOnlineRequest request.
true
if the user is online in the Buddy List system.
*/
getMyOnlineState(): boolean;
/**
* Returns the current user's nickname (if set).
*
* If the nickname was never set before, null
is returned.
* As the nickname of a user in a buddy list is handled by means of a reserved Buddy Variable (see ReservedBuddyVariables class), * it can be set using the SetBuddyVariablesRequest request.
* @returns The user nickname in the Buddy List system. */ getMyNickName(): string; /** * Returns the current user's custom state (if set). * * Examples of custom states are "Available", "Busy", "Be right back", etc. If the custom state was never set before,null
is returned.
* As the custom state of a user in a buddy list is handled by means of a reserved Buddy Variable (see ReservedBuddyVariables class), * it can be set using the SetBuddyVariablesRequest request.
* @returns The user state in the Buddy List system. */ getMyState(): string; /** * Returns a list of strings representing the available custom buddy states. * *The custom states are received by the client upon initialization of the Buddy List system. They can be configured by means of the SmartFoxServer 2X Administration Tool.
* @returns The list of available custom buddy states in the Buddy List system. */ getBuddyStates(): string[]; } /** * Developers never istantiate the SFSRoomManager class: this is done internally by the SmartFoxServer 2X API; get a reference to it using the SmartFox.roomManager property. * *This class keeps track of all the Rooms available in the client-side Rooms list and of subscriptions to multiple Room Groups. * It also provides various utility methods to look for Rooms by name and id, retrieve Rooms belonging to a specific Group, etc.
*/ export class SFSRoomManager { /** * Returns the names of Groups currently subscribed by the client. * *NOTE: at login time, the client automatically subscribes all the Room Groups specified in the Zone's Default Room Groups setting.
* @returns A list of Group names. */ getRoomGroups(): string[]; /** * Indicates whether the specified Group has been subscribed by the client or not. * @param groupId - The name of the Group. * @returnstrue
if the client subscribed the passed Group.
*/
containsGroup(groupId: string): boolean;
/**
* Indicates whether a Room exists in the Rooms list or not.
* @param idOrName - The id or name of the SFSRoom object whose presence in the Rooms list is to be tested.
* @returns true
if the passed Room exists in the Rooms list.
*/
containsRoom(idOrName: number | string): boolean;
/**
* Indicates whether the Rooms list contains a Room belonging to the specified Group or not.
* @param idOrName - The id or name of the SFSRoom object whose presence in the Rooms list is to be tested.
* @param groupId - The name of the Group to which the specified Room must belong.
* @returns true
if the Rooms list contains the passed Room and it belongs to the specified Group.
*/
containsRoomInGroup(idOrName: number | string, groupId: string): boolean;
/**
* Retrieves a SFSRoom object from its id property.
* @example
* undefined
if no SFSRoom object with the passed id exists in the Rooms list.
*/
getRoomById(id: number): SFSRoom;
/**
* Retrieves a SFSRoom object from its name property.
* @example
* undefined
if no SFSRoom object with the passed name exists in the Rooms list.
*/
getRoomByName(name: string): SFSRoom;
/**
* Returns a list of Rooms currently "known" by the client.
*
* The list contains all the Rooms that are currently joined and all the Rooms belonging to the Room Groups that have been subscribed.
* *NOTE: at login time, the client automatically subscribes all the Room Groups specified in the Zone's Default Room Groups setting.
* @returns The list of the available SFSRoom objects. */ getRoomList(): SFSRoom[]; /** * Returns the current number of Rooms in the Rooms list. * @returns The number of Rooms in the Rooms list. */ getRoomCount(): number; /** * Retrieves the list of Rooms which are part of the specified Room Group. * @param groupId - The name of the Group. * @returns The list of SFSRoom objects belonging to the passed Group. */ getRoomListFromGroup(groupId: string): SFSRoom[]; /** * Returns a list of Rooms currently joined by the client. * @returns The list of SFSRoom objects representing the Rooms currently joined by the client. */ getJoinedRooms(): SFSRoom[]; /** * Retrieves a list of Rooms joined by the specified user. * *The list contains only those Rooms "known" by the Room Manager; the user might have joined others the client is not aware of.
* @param user - A SFSUser object representing the user to look for in the current Rooms list. * @returns The list of Rooms joined by the passed user. */ getUserRooms(user: SFSUser): SFSRoom[]; } /** * Developers never istantiate the SFSUserManager class: this is done internally by the SmartFoxServer 2X API; get a reference to it using the SmartFox.userManager property. * *This class keeps track of all the users that are currently joined in the same Rooms of the current user. * It also provides utility methods to look for users by name and id.
*/ export class SFSUserManager { /** * Indicates whether a user exists in the local users list or not from the name. * @param userName - The name of the user whose presence in the users list is to be tested. * @returnstrue
if the passed user exists in the users list.
*/
containsUserName(userName: string): boolean;
/**
* Indicates whether a user exists in the local users list or not from the id.
* @param userId - The id of the user whose presence in the users list is to be tested.
* @returns true
if the passed user exists in the users list.
*/
containsUserId(userId: number): boolean;
/**
* Indicates whether a user exists in the local users list or not.
* @param user - The SFSUser object representing the user whose presence in the users list is to be tested.
* @returns true
if the passed user exists in the users list.
*/
containsUser(user: SFSUser): boolean;
/**
* Retrieves a SFSUser object from its id property.
* @param userId - The id of the user to be retrieved.
* @returns The SFSUser object representing the user, or undefined
if no user with the passed id exists in the local users list.
*/
getUserById(userId: number): SFSUser;
/**
* Retrieves a SFSUser object from its name property.
* @param userName - The name of the user to be retrieved.
* @returns The SFSUser object representing the user, or undefined
if no user with the passed name exists in the local users list.
*/
getUserByName(userName: string): SFSUser;
/**
* Returns the total number of users in the local users list.
* @returns The number of users in the local users list.
*/
getUserCount(): number;
/**
* Get the whole list of users inside the Rooms joined by the client.
* @returns The list of SFSUser objects representing the users in the local users list.
*/
getUserList(): SFSUser[];
}
/**
* Developers never istantiate the BaseRequest class; see the ...Request classes.
*/
export class BaseRequest {
}
/**
* Creates a new RoomSettings instance.
*
* The instance must be passed to the CreateRoomRequest class constructor.
* @param name - The name of the Room to be created. */ export class RoomSettings { constructor(name: string); /** * Defines the name of the Room. */ name: string; /** * Sets the password of the Room. * *If the password is set to an empty string, the Room won't be password protected.
*/ password: string; /** * Sets the id of the Group to which the Room should belong. * *If the Group doesn't exist yet, a new one is created before assigning the Room to it.
*/ groupId: string; /** * Sets whether the Room is a Game Room or not. */ isGame: boolean; /** * Sets the maximum number of users allowed in the Room. *In case of Game Rooms, this is the maximum number of players.
*/ maxUsers: number; /** * Sets the maximum number of spectators allowed in the Room (only for Game Rooms). */ maxSpectators: number; /** * Sets the maximum number of Room Variables allowed for the Room. */ maxVariables: number; /** * Sets a list of SFSRooomVariable objects to be attached to the Room. */ variables: SFSRoomVariable[]; /** * Sets the flags indicating which operations are permitted on the Room. * *Permissions include: name and password change, maximum users change and public messaging.
* If set to null
, the permissions configured on the server-side are used (see the SmartFoxServer 2X Administration Tool documentation).
Room events include: users entering or leaving the room, user count change and user variables update.
* If set to null
, the events configured on the server-side are used (see the SmartFoxServer 2X Administration Tool documentation).
The instance must be passed to the CreateSFSGameRequest class constructor.
* *On the server-side, a Game Room is represented by the SFSGame Java class which extends the Room class
* providing new advanced features such as player matching, game invitations, public and private games, quick game joining, etc.
* On the client side Game Rooms are regular Rooms with their isGame property set to true
.
A public game can be joined by any player whose User Variables match the playerMatchExpression assigned to the Game Room. * A private game can be joined by users invited by the game creator by means of invitedPlayers list.
*/ isPublic: boolean; /** * Defines the minimum number of players required to start the game. * *If the notifyGameStarted property is set to true
, when this number is reached, the game start is notified.
If the invitations are less than the minimum number of players required to start the game (see the minPlayersToStartGame property), * the server will send additional invitations automatically, searching users in the Room Groups specified in the searchableRooms list * and filtering them by means of the object passed to the playerMatchExpression property.
* *The game matching criteria contained in the playerMatchExpression property do not apply to the users specified in this list.
*/ invitedPlayers: SFSUser[]; /** * In private games, defines a list of Groups names where to search players to invite. * *If the users invited to join the game (specified through the invitedPlayers property) are less than the minimum number of * players required to start the game (see the minPlayersToStartGame property), * the server will invite others automatically, searching them in Rooms belonging to the Groups specified in this list * and filtering them by means of the object passed to the playerMatchExpression property.
*/ searchableRooms: string[]; /** * In private games, defines the number of seconds that users have to reply to the invitation to join a game. * *The suggested range is 10 to 40 seconds.
*/ invitationExpiryTime: number; /** * In private games, indicates whether the players must leave the previous Room when joining the game or not. * *This setting applies to private games only because users join the Game Room automatically when they accept the invitation to play, * while public games require a JoinRoomRequest request to be sent, where this behavior can be determined manually.
*/ leaveLastJoinedRoom: boolean; /** * Indicates if a game state change must be notified when the minimum number of players is reached. * *If this setting is true
, the game state (started or stopped) is handled by means of the reserved Room Variable
* represented by the ReservedRoomVariables.RV_GAME_STARTED constant. Listening to the roomVariablesUpdate event for this variable
* allows clients to be notified when the game can start due to minimum number of players being reached.
As the used Room Variable is created as global (see the SFSRoomVariable class description), its update is broadcast outside the Room too: * this can be used on the client-side, for example, to show the game state in a list of available games.
*/ notifyGameStarted: boolean; /** * Defines the game matching expression to be used to filters players. * *Filtering is applied when:
*Filtering is not applied to users invited by the creator to join a private game (see the invitedPlayers property).
*/ playerMatchExpression: MatchExpression; /** * Defines the game matching expression to be used to filters spectators. * *Filtering is applied when users try to join a public Game Room as spectators (their User Variables must match the matching criteria).
*/ spectatorMatchExpression: MatchExpression; /** * In private games, defines an optional SFSObject containing additional custom parameters to be sent together with the invitation. * *Possible custom parameters to be transferred to the invitees are a message for the recipient, the game details (title, type...), the inviter details, etc.
*/ invitationParams: SFSObject; } /** * Creates a new MMORoomSettings instance. * *The instance must be passed to the CreateRoomRequest class constructor.
* @param name - The name of the MMORoom to be created. * @param defaultAOI - The Area of Interest (AoI) for the MMORoom to be created. */ export class MMORoomSettings { constructor(name: string, defaultAOI: Vec3D); /** * Defines the Area of Interest (AoI) for the MMORoom. * *This value represents the area/range around the user that will be affected by server events and other users events.
* It is a Vec3D object providing 2D or 3D coordinates. For example a Vec3D(50,50)
describes a range of 50 units (e.g. pixels) in all four directions (top, bottom, left, right)
* with respect to the user position in a 2D coordinates system. A Vec3D(120,120,60)
instead describes a range of 120 units in all four directions (top, bottom, left, right)
* and 60 units along the two Z-axis directions (backward, forward) with respect to the user position in a 3D coordinates system.
When specified, this property must contain two non-null Vec3D objects representing the minimum and maximum limits of the 2D/3D coordinates systems. * Any positional value that falls outside the provided limit will be refused by the server.
* *This setting is optional but its usage is highly recommended.
*/ mapLimits: MapLimits; /** * Defines the time limit before a user without a physical position set inside the MMORoom is kicked from the Room. * *As soon as the MMORoom is joined, the user still doesn't have a physical position set in the coordinates system, therefore it is * considered in a "limbo" state. At this point the user is expected to set his position (via the SetUserPositionRequest request) within the * amount of seconds expressed by this value.
*/ userMaxLimboSeconds: number; /** * Configures the speed at which the SFSEvent.PROXIMITY_LIST_UPDATE event is sent by the server. * *In an MMORoom, the regular users list is replaced by a proximity list, which keeps an updated view of the users currently within the Area of Interest * of the current user. The speed at which these updates are fired by the server is regulated by this parameter, which sets the minimum time between two subsequent updates.
* *NOTE: values below the default might be unnecessary for most applications unless they are in realtime.
*/ proximityListUpdateMillis: number; /** * Sets if the users entry points in the current user's Area of Interest should be transmitted in the SFSEvent.PROXIMITY_LIST_UPDATE event. * *If this setting is set to true
, when a user enters the AoI of another user, the server will also send the coordinates
* at which the former "appeared" within the AoI. This option should be turned off in case these coordinates are not needed, in order to save bandwidth.
The instance must be passed to the ClusterJoinOrCreateRequest class constructor.
* *On the server-side, a Game Room is represented on the Game Node by the SFSGame Java class, which extends the Room class
* providing advanced features such as player matching, game invitations, public and private games, quick game joining, etc.
* On the client side Game Rooms are regular Rooms with their isGame property set to true
.
A public game can be joined by any player whose User Variables match the playerMatchExpression assigned to the Game Room. * A private game can be joined by users invited by the game creator by means of invitedPlayers list.
*/ isPublic: boolean; /** * Defines the minimum number of players required to start the game. * *If the notifyGameStarted property is set to true
, when this number is reached, the game start is notified.
The suggested range is 30 to 60 seconds.
*/ invitationExpiryTime: number; /** * Indicates if a game state change must be notified when the minimum number of players is reached. * *If this setting is true
, the game state (started or stopped) is handled by means of the reserved Room Variable
* represented by the ReservedRoomVariables.RV_GAME_STARTED constant. Listening to the roomVariablesUpdate event for this variable
* allows clients to be notified when the game can start due to minimum number of players being reached.
Possible custom parameters to be transferred to the invitees are a message for the recipient, the game details (title, type...), the inviter details, etc.
*/ invitationParams: SFSObject; } /** * Creates a new RoomPermissions instance. * *The RoomSettings.permissions property must be set to this instance during Room creation.
*/ export class RoomPermissions { /** * Sets whether changing the Room name after its creation is allowed or not. * *The Room name can be changed by means of the ChangeRoomNameRequest request.
*/ allowNameChange: boolean; /** * Sets whether changing (or removing) the Room password after its creation is allowed or not. * *The Room password can be changed by means of the ChangeRoomPasswordStateRequest request.
*/ allowPasswordStateChange: boolean; /** * Sets whether users inside the Room are allowed to send public messages or not. * *Public messages can be sent by means of the PublicMessageRequest request.
*/ allowPublicMessages: boolean; /** * Sets whether the Room capacity can be changed after its creation or not. * *The capacity is the maximum number of users and spectators (in Game Rooms) allowed to enter the Room. * It can be changed by means of the ChangeRoomCapacityRequest request.
*/ allowResizing: boolean; } /** * Creates a new RoomEvents instance. * *The RoomSettings.events property must be set to this instance during Room creation.
*/ export class RoomEvents { /** * Sets whether or not the userCountChange event should be dispatched whenever the users (or players+spectators) count changes in the Room. */ allowUserCountChange: boolean; /** * Sets whether the userEnterRoom event should be dispatched whenever a user joins the Room or not. */ allowUserEnter: boolean; /** * Sets whether the userExitRoom event should be dispatched whenever a user leaves the Room or not. */ allowUserExit: boolean; /** * Sets whether or not the userVariablesUpdate event should be dispatched whenever a user in the Room updates his User Variables. */ allowUserVariablesUpdate: boolean; } /** * Creates a new RoomExtension instance. * *The RoomSettings.extension property must be set to this instance during Room creation.
* @param id - The name of the Extension as deployed on the server; it's the name of the folder containing the Extension classes inside the main [sfs2x-install-folder]/SFS2X/extensions folder. * @param className - The fully qualified name of the main class of the Extension. */ export class RoomExtension { constructor(id: string, className: string); /** * Returns the name of the Extension to be attached to the Room. * *It's the name of the server-side folder containing the Extension classes inside the main [sfs2x-install-folder]/SFS2X/extensions folder.
*/ id: string; /** * Returns the fully qualified name of the main class of the Extension. */ className: string; /** * Sets the name of an optional properties file that should be loaded on the server-side during the Extension initialization. * *The file must be located in the server-side folder containing the Extension classes (see the id property).
*/ propertiesFile: string; } /** * Creates a new MapLimits instance. * *The MMORoomSettings.mapLimits property must be set to this instance during MMORoom creation.
* @param lowerLimit - The lower coordinates limit of the virtual environment along the X,Y,Z axes. * @param higherLimit - The higher coordinates limit of the virtual environment along the X,Y,Z axes. */ export class MapLimits { constructor(lowerLimit: Vec3D, higherLimit: Vec3D); /** * Returns the lower coordinates limit of the virtual environment along the X,Y,Z axes. */ lowerLimit: Vec3D; /** * Returns the higher coordinates limit of the virtual environment along the X,Y,Z axes. */ higherLimit: Vec3D; } /** * Developers never istantiate the BanMode class: only use its static properties. */ export class BanMode { constructor(); /** * User is banned by IP address. */ static readonly BY_ADDRESS: number; /** * User is banned by name. */ static readonly BY_NAME: number; } /** * Creates a new MessageRecipientMode instance. * *The instance must be passed as recipientMode parameter to the ModeratorMessageRequest and AdminMessageRequest classes constructors.
* @param mode - One of the costants contained in this class, describing the recipient mode. * @param target - The moderator/administrator message recipient/s, according to the selected recipient mode. */ export class MessageRecipientMode { constructor(mode: number, target: SFSUser | SFSRoom | string); /** * The moderator/administrator message will be sent to a specific user. *A SFSUser instance must be passed as target parameter to the class constructor.
*/ static readonly TO_USER: number; /** * The moderator/administrator message will be sent to all the users in a specific Room. *A SFSRoom instance must be passed as target parameter to the class constructor.
*/ static readonly TO_ROOM: number; /** * The moderator/administrator message will be sent to all the clients who subscribed a specific Room Group. *A Group id must be passed as target parameter to the class constructor.
*/ static readonly TO_GROUP: number; /** * The moderator/administrator message will be sent to all the users in the Zone. *null
can be passed as target parameter, in fact it will be ignored.
The instance must be passed as target parameter to the ClusterInviteUsersRequest class constructor.
* @param nodeId - The identifier of the Game Node where the Room is located. * @param roomId - The identifier of the Room on the Game Node. */ export class ClusterTarget { constructor(nodeId: string, roomId: number); /** * Indicates the identifier of the Game Node where the Room is located. */ readonly nodeId: string; /** * Indicates the identifier of the Room on the Game Node. */ readonly roomId: number; } /** * Creates a new AddBuddyRequest instance. * The instance must be passed to the SmartFox.send() method for the request to be executed. * *In order to add a buddy, the current user must be online in the Buddy List system. If the buddy is added successfully, the operation is confirmed by a buddyAdd event; * otherwise the buddyError event is fired.
* *NOTE: this request can be sent if the Buddy List system was previously initialized only (see the InitBuddyListRequest request description).
* @example *Blocked buddies won't be able to see if the user who blocked them is online in their buddy list; they also won't be able to send messages or requests to that user.
* *In order to block a buddy, the current user must be online in the Buddy List system. If the operation is successful, a buddyBlock confirmation event is dispatched; * otherwise the buddyError event is fired.
* *NOTE: this request can be sent if the Buddy List system was previously initialized only (see the InitBuddyListRequest request description).
* @example *true
if the buddy must be blocked; false
if he must be unblocked.
*/
export class BlockBuddyRequest {
constructor(buddyName: string, blocked: boolean);
}
/**
* Creates a new BuddyMessageRequest instance.
* The instance must be passed to the SmartFox.send() method for the request to be executed.
*
* Messages sent to buddies using the BuddyMessageRequest request are similar to the standard private messages (see the PrivateMessageRequest request) * but are specifically designed for the Buddy List system: they don't require any Room parameter, nor they require that users joined a Room. * Additionally, buddy messages are subject to specific validation, such as making sure that the recipient is in the sender's buddies list and the sender is not blocked by the recipient.
* *If the operation is successful, a buddyMessage event is dispatched in both the sender and recipient clients.
* *NOTE: this request can be sent if the Buddy List system was previously initialized only (see the InitBuddyListRequest request description).
* @example *All clients who have the current user as buddy in their buddy list will receive the buddyOnlineStateChange event and see the SFSBuddy.isOnline property return its value accordingly. * The same event is also dispatched to the current user, who sent the request, so that the application interface can be updated accordingly. * Going online/offline as buddy doesn't affect the user connection, the currently joined Zone and Rooms, etc.
* *The online state of a user in a buddy list is handled by means of a reserved and persistent Buddy Variable.
* *NOTE: this request can be sent if the Buddy List system was previously initialized only (see the InitBuddyListRequest request description).
* @example *true
to make the current user available (online) in the Buddy List system; false
to make him not available (offline).
*/
export class GoOnlineRequest {
constructor(online: boolean);
}
/**
* Creates a new InitBuddyListRequest instance.
* The instance must be passed to the SmartFox.send() method for the request to be executed.
*
* Buddy List system initialization involves loading any previously stored buddy-specific data from the server, such as the current user's buddy list, his previous state and the persistent Buddy Variables. * The initialization request is the first operation to be executed in order to be able to use the Buddy List system features. * Once the initialization is completed, the buddyListInit event id fired and the user has access to all his data set previously and he can start to interact with his buddies; * if the initialization fails, a buddyError event is fired.
* @example *In order to remove a buddy, the current user must be online in the Buddy List system. If the buddy is removed successfully, the operation is confirmed by a buddyRemove event; * otherwise the buddyError event is fired.
* *NOTE: this request can be sent if the Buddy List system was previously initialized only (see the InitBuddyListRequest request description).
* @example *This operation updates the SFSBuddy object representing the user in all the buddy lists in which the user was added as a buddy. * If the operation is successful, a buddyVariablesUpdate event is dispatched to all the owners of those buddy lists and to the user who updated his variables too.
* *The Buddy Variables can be persisted, which means that their value will be saved even it the user disconnects and it will be restored when he connects again. * In order to make a variable persistent, put the constant SFSBuddyVariable.OFFLINE_PREFIX before its name. Read the SmartFoxServer 2X documentaion about the Buddy List API for more informations.
* *NOTE: this request can be sent if the Buddy List system was previously initialized only (see the InitBuddyListRequest request description) * and the current user state in the system is "online".
* @example *In the SmartFoxServer 2X Cluster environment, this request sends a generic invitation to a list of users to join a Room on a Game Node. * Invitations can be used for different purposes, such as requesting users to join a game or visit a specific Room, asking the permission to add them as buddies, etc. * Invited users receive the invitation as an invitation event dispatched to their clients: they can accept or refuse it * by means of the InvitationReplyRequest request, which must be sent within the specified amount of time.
*If the invitation is accepted, and the invited user is not yet connected to the target Game Node, the connectionRequired event * is dispatched to the their client, followed by a roomJoin event after the connection and login process is completed. * In case the client is already connected to the target Game Node, the roomJoin event is received immediately.
* @example *The Lobby Node searches for a public Game Room that meets the criteria expressed by the passed matching expression in the passed Room Groups. * If no suitable Game Room can be found or a null matching expression is passed, and if the settings parameter is set, a new Game Room * is created on a Game Node selected by the cluster's load balancing system.
* *In any case, if a game to join can be found or is created, the connectionRequired event is dispatched to the requester's client, * followed by a roomJoin event after the connection and login process is completed. * In case the client is already connected to the target Game Node, the roomJoin event is received immediately.
* @example *null
, a new Game Room will be created.
* @param groupList - A list of group names to further filter the search; if null
, all groups will be searched.
* @param settings - If no Rooms are found through the matching expression, a new Room with the passed settings will be created and the user will auto-join it.
*/
export class ClusterJoinOrCreateRequest {
constructor(matchExpression: MatchExpression, groupList: string[], settings: MMORoomSettings | ClusterRoomSettings);
}
/**
* Creates a new CreateSFSGameRequest instance.
* The instance must be passed to the SmartFox.send() method for the request to be executed.
*
* This request creates a new Game Room in the current Zone through the istantiation of a SFSGame object on the server-side, * a specialized Room type that provides advanced features during the creation phase of a game. * Specific game-configuration settings are passed by means of the SFSGameSettings class.
* *If the creation is successful, a roomAdd event is dispatched to all the users who subscribed the Group to which the Room is associated, including the game creator.
* Otherwise, a roomCreationError event is returned to the creator's client.
* Also, if the settings passed in the SFSGameSettings object cause invitations to join the game to be sent, an invitation event is
* dispatched to all the recipient clients.
Check the SmartFoxServer 2X documentation for a more in-depth overview of the GAME API.
* @example *Users who receive an invitation sent by means of the InviteUsersRequest request can either accept or refuse it using this request. * The reply causes an invitationReply event to be dispatched to the inviter; if a reply is not sent, or it is sent after the invitation expiration, * the system will react as if the invitation was refused.
* *If an error occurs while the reply is delivered to the inviter user (for example the invitation is already expired), * an invitationReplyError event is returned to the current user.
* @example *This request sends a generic invitation to a list of users. * Invitations can be used for different purposes, such as requesting users to join a game or visit a specific Room, asking the permission to add them as buddies, etc. * Invited users receive the invitation as an invitation event dispatched to their clients: they can accept or refuse it * by means of the InvitationReplyRequest request, which must be sent within the specified amount of time.
* @param invitedUsers - A list of SFSUser objects, each representing a user to send the invitation to. * @param secondsForAnswer - The number of seconds available to each invited user to reply to the invitation (recommended range: 15 to 40 seconds). * @param [params = null] - An SFSObject containing custom parameters containing additional invitation details. */ export class InviteUsersRequest { constructor(invitedUsers: SFSUser[], secondsForAnswer: number, params?: SFSObject); } /** * Creates a new JoinRoomInvitationRequest instance. * The instance must be passed to the SmartFox.send() method for the request to be executed. * *This request invites other users/players to join a Room. Invited users receive the invitation as an invitation event dispatched to their clients: they can accept or refuse it * by means of the InvitationReplyRequest request, which must be sent within the specified amount of time. If the invitation is accepted, the client automatically joins the target Room.
* *Depending on the Room's settings this invitation can be sent by the Room's owner only or by any other user in the Room. * This behavior can be set via the RoomSettings.allowOwnerOnlyInvitation parameter.
* *NOTE: spectators in a Game Room are not allowed to invite other users; only players are.
* *An invitation can also specify the amount of time given to each invitee to reply. Default is 30 seconds. A positive answer will attempt to join the user in the designated Room. * For Game Rooms the asSpectator flag can be toggled to join the invitee as player or spectator (default = player).
* *There aren't any specific notifications sent back to the inviter after the invitee's response. Users that have accepted the invitation will join the Room while those * who didn't reply or turned down the invitation won't generate any event. In order to send specific messages (e.g. chat), just send a private message back to the inviter.
* @example *Using this request, by providing a matching expression and a list of Rooms or Groups, SmartFoxServer can search for a matching public Game Room * and immediately join the user into that Room as a player.
* *If a game is found and can be joined, the roomJoin event is dispatched to the requester's client.
* @example *null
is passed, the first available game Room is joined.
* @param whereToSearch - An array of SFSRoom objects or an array of Group names to which the matching expression should be applied. The maximum number of elements that this array can contain is 32.
* @param [roomToLeave = null] - A SFSRoom object representing the Room that the user should leave when joining the game.
*/
export class QuickJoinGameRequest {
constructor(matchExpression: MatchExpression, whereToSearch: SFSRoom[], roomToLeave?: SFSRoom);
}
/**
* Creates a new SetUserPositionRequest instance.
* The instance must be passed to the SmartFox.send() method for the request to be executed.
*
* MMORooms represent virtual environments and can host any number of users. Based on their position, the system allows users within a certain range from each other (Area of Interest, or AoI) to interact.
* This request allows the current user to update his position inside the MMORoom, which in turn will trigger a proximityListUpdate event for all users that fall within his AoI.
null
, the last Room joined by the user is used.
*/
export class SetUserPositionRequest {
constructor(pos: Vec3D, targetRoom?: MMORoom);
}
/**
* Creates a new BanUserRequest instance.
* The instance must be passed to the SmartFox.send() method for the request to be executed.
*
* This request banishes a user from the server. The current user must have administration or moderation privileges in order to be able to ban another user (see the SFSUser.privilegeId property). * The user can be banned by name or by IP address (see the BanMode class). Also, the request allows sending a message to the banned user * (to make clear the reason of the following disconnection) which is delivered by means of the moderatorMessage event.
* *Differently from the user being kicked (see the KickUserRequest request), a banned user won't be able to connect to the SmartFoxServer instance until * the banishment expires (after 24 hours for client-side banning) or an administrator removes his name/IP address from the list of banned users * by means of the SmartFoxServer 2X Administration Tool.
* @example *null
, the default message configured in the SmartFoxServer 2X Administration Tool is used.
* @param [banMode = BanMode.BY_NAME] - One of the ban modes defined in the BanMode class.
* @param [delaySeconds = 5] - The number of seconds after which the user is banned after receiving the ban message.
* @param [durationHours = 24] - The duration of the banishment, expressed in hours.
*/
export class BanUserRequest {
constructor(userId: number, message?: string, banMode?: number, delaySeconds?: number, durationHours?: number);
}
/**
* Creates a new ChangeRoomCapacityRequest instance.
* The instance must be passed to the SmartFox.send() method for the request to be executed.
*
* This request changes the maximum number of users and/or spectators who can join a Room. * If the operation is successful, the roomCapacityChange event is dispatched to all the users * who subscribed the Group to which the target Room belongs, including the requester user himself. * If the user is not the creator (owner) of the Room, the roomCapacityChangeError event is fired. * An administrator or moderator can override this constrain (he is not requested to be the Room's owner).
* *Please note that some limitations are applied to the passed values (i.e. a client can't set the max users to more than 200, or the max spectators to more than 32). * Also, if the Room was configured so that resizing is not allowed (see the RoomSettings.permissions parameter), the request is ignored and no error is fired.
* *In case the Room's capacity is reduced to a value less than the current number of users/spectators inside the Room, exceeding users are NOT disconnected.
* @example *This request changes the name of a Room. If the renaming operation is successful, the roomNameChange event is dispatched to all the users * who subscribed the Group to which the target Room belongs, including the user who renamed it. * If the user is not the creator (owner) of the Room, or if the new name doesn't match the related criteria in Zone configuration, * the roomNameChangeError event is fired. An administrator or moderator can override this constrain (he is not requested to be the Room's owner).
*If the Room was configured so that renaming is not allowed (see the RoomSettings.permissions parameter), the request is ignored and no error is fired.
* @example *This request not only changes the password of a Room, but also its "password state", which indicates if the Room is password protected or not.
* *If the operation is successful, the roomPasswordStateChange event is dispatched to all the users * who subscribed the Group to which the target Room belongs, including the requester user himself. * If the user is not the creator (owner) of the Room, the roomPasswordStateChangeError event is fired. * An administrator or moderator can override this constrain (he is not requested to be the Room's owner).
*If the Room was configured so that password change is not allowed (see the RoomSettings.permissions parameter), the request is ignored and no error is fired.
* @example *null
value can be passed to remove the Room's password.
*/
export class ChangeRoomPasswordStateRequest {
constructor(room: SFSRoom, newPass: string);
}
/**
* Creates a new CreateRoomRequest instance.
* The instance must be passed to the SmartFox.send() method for the request to be executed.
*
* This request creates a new Room in the current Zone. If the creation is successful, * a roomAdd event is dispatched to all the users who subscribed the Group to which the Room is associated, including the Room creator. * Otherwise, a roomCreationError event is returned to the creator's client.
* @example *true
, the Room is joined as soon as it is created.
* @param [roomToLeave = null] - A SFSRoom object representing the Room that should be left if the new Room is auto-joined.
*/
export class CreateRoomRequest {
constructor(settings: RoomSettings, autoJoin?: boolean, roomToLeave?: SFSRoom);
}
/**
* Creates a new ExtensionRequest instance.
* The instance must be passed to the SmartFox.send() method for the request to be executed.
*
* This request is used to send custom commands from the client to a server-side Extension, be it a Zone-level or Room-level Extension. * Viceversa, the extensionResponse event is used by the server to send Extension commands/responses to the client.
* *Read the SmartFoxServer 2X documentation about server-side Extension for more informations.
* @example *null
, the specified command is sent to the current Zone server-side Extension; if not null
, the command is sent to the server-side Extension attached to the passed Room.
*/
export class ExtensionRequest {
constructor(extCmd: string, params?: SFSObject, room?: SFSRoom);
}
/**
* Creates a new FindRoomsRequest instance.
* The instance must be passed to the SmartFox.send() method for the request to be executed.
*
* By providing a matching expression and a search scope (a Group or the entire Zone), with this request it is possible to find those Rooms * matching the passed criteria on the server side and retrieve them by means of the roomFindResult event.
* @example *null
, the search is executed in the whole Zone.
* @param [limit = 0] - The maximum size of the list of Rooms that will be returned by the roomFindResult event. If 0
, all the found Rooms are returned.
*/
export class FindRoomsRequest {
constructor(expr: MatchExpression, groupId?: string, limit?: number);
}
/**
* Creates a new FindUsersRequest instance.
* The instance must be passed to the SmartFox.send() method for the request to be executed.
*
* By providing a matching expression and a search scope (a Room, a Group or the entire Zone), with this request it is possible to find those users * matching the passed criteria on the server side and retrieve them by means of the userFindResult event.
* @example *null
, the search is executed in the whole Zone.
* @param [limit = 0] - The maximum size of the list of users that will be returned by the userFindResult event. If 0
, all the found users are returned.
*/
export class FindUsersRequest {
constructor(expr: MatchExpression, target?: string | SFSRoom, limit?: number);
}
/**
* Creates a new JoinRoomRequest instance.
* The instance must be passed to the SmartFox.send() method for the request to be executed.
*
* This request joins the current user in a Room. If the operation is successful, the current user receives a roomJoin event; * otherwise the roomJoinError event is fired. This usually happens when the Room is full, or the password is wrong in case of password protected Rooms.
* *Depending on the Room configuration defined upon its creation (see the RoomSettings.events setting), when the current user joins it, * the following events might be fired: userEnterRoom, dispatched to the other users inside the Room to warn them that a new user has arrived; * userCountChange, dispatched to all clients which subscribed the Group to which the Room belongs, to update the count of users inside the Room.
* @example *true
to join the Room as a spectator (in Game Rooms only).
*/
export class JoinRoomRequest {
constructor(room: number | string | SFSRoom, password?: string, roomIdToLeave?: number, asSpectator?: boolean);
}
/**
* Creates a new KickUserRequest instance.
* The instance must be passed to the SmartFox.send() method for the request to be executed.
*
* This request kicks a user out of the server. The current user must have administration or moderation privileges in order to be able to kick another user (see the SFSUser.privilegeId property). * The request allows sending a message to the kicked user (to make clear the reason of the following disconnection) which is delivered by means of the moderatorMessage event.
* *Differently from the user being banned (see the BanUserRequest request), a kicked user will be able to reconnect to the SmartFoxServer instance immediately.
* @example *null
, the default message configured in the SmartFoxServer 2X Administration Tool is used.
* @param [delaySeconds = 5] - The number of seconds after which the user is kicked after receiving the kick message.
*/
export class KickUserRequest {
constructor(userId: number, message?: string, delaySeconds?: number);
}
/**
* Creates a new LeaveRoomRequest instance.
* The instance must be passed to the SmartFox.send() method for the request to be executed.
*
* This request makes the current user leave one of the Rooms he joined. Depending on the Room configuration defined upon its creation * (see the RoomSettings.events setting), when the user leaves it, the following events might be fired: userExitRoom, * dispatched to all the users inside the Room (including the current user then) to warn them that a user has gone away; * userCountChange, dispatched to all clients which subscribed the Group to which the Room belongs, to update the count of users inside the Room.
* @example *null
, the last Room joined by the user is left.
*/
export class LeaveRoomRequest {
constructor(room?: SFSRoom);
}
/**
* Creates a new LoginRequest instance.
* The instance must be passed to the SmartFox.send() method for the request to be executed.
*
* This requests logs the current user in one of the server Zones. Each Zone represent an indipendent multiuser application governed by SmartFoxServer. * In order to join a Zone, a user name and password are usually required. If the user credentials must be validated, * a custom login process should be implemented in the Zone's server-side Extension.
* *Read the SmartFoxServer 2X documentation about the login process for more informations.
* *If the login operation is successful, the current user receives a login event; otherwise the loginError event is fired.
* @example *This request logs the user out of the current server Zone. The user is notified of the logout operation by means of the logout event. * This doesn't shut down the connection, so the user will be able to login again in the same Zone or in a different one right after the confirmation event.
* @example *This request sends an object containing custom data to the users in a Room. * The object is delivered to the selected users (or all users excluding the sender) inside the target Room by means of the objectMessage event. * It can be useful to send game data, like for example the target coordinates of the user's avatar in a virtual world.
* @example *null
, the last Room joined by the user is used.
* @param [recipients = null] - A list of SFSUser objects corresponding to the message recipients; if null
, the message is sent to all users in the target Room (except the sender himself).
*/
export class ObjectMessageRequest {
constructor(object: SFSObject, targetRoom?: SFSRoom, recipients?: SFSUser[]);
}
/**
* Creates a new PublicMessageRequest instance.
* The instance must be passed to the SmartFox.send() method for the request to be executed.
*
* Using this request a public message is dispatched to all the users in the specified Room, including the message sender (this allows showing * chat messages in the correct order in the application interface); the corresponding event is the publicMessage event. * It is also possible to send an optional object together with the message: it can contain custom parameters useful to transmit, for example, additional * informations related to the message, like the text font or color, or other formatting details.
* *In case the target Room is not specified, the message is sent in the last Room joined by the sender.
* *NOTE: the publicMessage event is dispatched if the Room is configured to allow public messaging only (see the RoomSettings.permissions parameter).
* @example *null
, the last Room joined by the user is used.
*/
export class PublicMessageRequest {
constructor(message: string, params?: SFSObject, targetRoom?: SFSRoom);
}
/**
* Creates a new PrivateMessageRequest instance.
* The instance must be passed to the SmartFox.send() method for the request to be executed.
*
* Using this request a private message is dispatched to a specific user, who can be in any server Room, or even in no Room at all. * The message is delivered by means of the privateMessage event. * It is also returned to the sender: this allows showing the messages in the correct order in the application interface. * It is also possible to send an optional object together with the message: it can contain custom parameters useful to transmit, for example, additional * informations related to the message, like the text font or color, or other formatting details.
* @example *This request sends a moderator message to a specific user or to a group of users. * The current user must have moderation privileges to be able to send the message (see the SFSUser.privilegeId property).
* *The recipientMode parameter in the class constructor is used to determine the message recipients: a single user or all the * users in a Room, a Group or the entire Zone. Upon message delivery, the clients of the recipient users dispatch the moderatorMessage event.
* @example *This request sends an administrator message to a specific user or to a group of users. * The current user must have administration privileges to be able to send the message (see the SFSUser.privilegeId property).
* *The recipientMode parameter in the class constructor is used to determine the message recipients: a single user or all the * users in a Room, a Group or the entire Zone. Upon message delivery, the clients of the recipient users dispatch the adminMessage event.
* @example *This request turns the current user from player to spectator in a Game Room. If the operation is successful, * all the users in the target Room are notified with the playerToSpectator event. * The operation could fail if no spectator slots are available in the Game Room at the time of the request; in this case * the playerToSpectatorError event is dispatched to the requester's client.
* @example *null
, the last Room joined by the user is used.
*/
export class PlayerToSpectatorRequest {
constructor(targetRoom?: SFSRoom);
}
/**
* Creates a new QuickJoinOrCreateRoomRequest instance.
* The instance must be passed to the SmartFox.send() method for the request to be executed.
*
* SmartFoxServer searches for a public Room that meets the criteria expressed by the passed matching expression in the passed Room Groups. *
If no suitable Room can be found, a new Room is created, based on the passed settings. If a Room is created, the roomAdd event is dispatched to all the users who subscribed the Group to which the Room is associated, including the Room creator. In any case, if a Room to join could be found or was created, the roomJoin event is then dispatched.
*Error conditions (Room creation error, Room join error) should always be checked adding the appropriate listeners.
* @example *This request sets one or more custom Room Variables in a Room. When a Room Variable is set, the roomVariablesUpdate event * is dispatched to all the users in the target Room, including the user who updated it. * Also, if the Room Variable is global (see the SFSRoomVariable class description), the event is dispatched * to all users who subscribed the Group to which the target Room is associated.
* @example *null
, the last Room joined by the current user is used.
*/
export class SetRoomVariablesRequest {
constructor(roomVariables: SFSRoomVariable[], room?: SFSRoom);
}
/**
* Creates a new SetUserVariablesRequest instance.
* The instance must be passed to the SmartFox.send() method for the request to be executed.
*
* This request sets one or more User Variables for the current user. When a User Variable is set, the userVariablesUpdate event * is dispatched to all the users in all the Rooms joined by the current user, including himself.
* *NOTE: the userVariablesUpdate event is dispatched to users in a specific Room only if * it is configured to allow this event (see the RoomSettings.permissions parameter).
* @example *This request turns the current user from spectator to player in a Game Room. If the operation is successful, * all the users in the target Room are notified with the spectatorToPlayer event. * The operation could fail if no player slots are available in the Game Room at the time of the request; in this case * the spectatorToPlayerError event is dispatched to the requester's client.
* @example *null
, the last Room joined by the user is used.
*/
export class SpectatorToPlayerRequest {
constructor(targetRoom?: SFSRoom);
}
/**
* Creates a new SubscribeRoomGroupRequest instance.
* The instance must be passed to the SmartFox.send() method for the request to be executed.
*
* This request allows the user to be notified of specific Room events even if he didn't join the Room from which the events originated, provided the Room belongs to the subscribed Group.
* If the subscription operation is successful, the current user receives a roomGroupSubscribe event; otherwise the roomGroupSubscribeError event is fired.
This request allows the user to stop being notified of specific Room events occurring in Rooms belonging to the unsubscribed Group.
* If the operation is successful, the current user receives a roomGroupUnsubscribe event; otherwise the roomGroupUnsubscribeError event is fired.
NOTE: you have to make sure you maintain all the placeholders while modifying a message.
* @example *Client operations are not compromised when a warning is raised.
*/ static readonly WARN: number; /** * An ERROR message contains informations on a problem that occurred during the client activities. *Client operations might be compromised when an error is raised.
*/ static readonly ERROR: number; } /** * Developers never istantiate the LoggerEvent class: only use its static properties. * *The constants contained in this class are used to register the logging event listeners; when an event is dispatched, an object containing the logged message is passed to the listener.
* @example *Property | Type | Description |
---|---|---|
message | string | The logged debug message. |
Property | Type | Description |
---|---|---|
message | string | The logged informative message. |
Property | Type | Description |
---|---|---|
message | string | The logged warning message. |
Property | Type | Description |
---|---|---|
message | string | The logged error message. |
Accessing the logger instance allows to control the client-side logging level by means of the level property.
*/ export class Logger extends EventDispatcher { /** * Gets and sets the current logging level. * *Debugging messages with a level lower than this value are not logged.
* The available log levels are contained in the LogLevel class. The default value is LogLevel.INFO.
This property has no effect if the "console" object is undefined in the current environment.
*/ enableConsoleOutput: boolean; /** * Indicates whether dispatching of log events is enabled or not. */ enableEventDispatching: boolean; /** * Registers an event listener function that will receive notification of an event. * *If you no longer need an event listener, remove it by calling the removeEventListener() method, or memory issues could arise. * In fact event listeners are not automatically removed from memory.
* @example *The connection timeout depends on the server settings.
*/ static readonly IDLE: string; /** * Client was kicked out of the server. *Kicking can occur automatically (i.e. for swearing, if the words filter is active) * or due to the intervention of a user with enough privileges (i.e. an administrator or a moderator).
*/ static readonly KICK: string; /** * Client was banned from the server. *Banning can occur automatically (i.e. for flooding, if the flood filter is active) * or due to the intervention of a user with enough privileges (i.e. an administrator or a moderator).
*/ static readonly BAN: string; /** * The client manually disconnected from the server. *The disconnect() method on the SmartFox class was called.
*/ static readonly MANUAL: string; /** * A generic network error occurred, and the client is unable to determine the cause of the disconnection. *The server-side log should be checked for possible error messages or warnings.
*/ static readonly UNKNOWN: string; } /** * Developers never istantiate the PasswordUtil class: only use its static properties. */ export class PasswordUtil { /** * Generates the MD5 hash of a user password. * @example *