rubyfox-server 2.12.5.1 → 2.13.3.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/rubyfox/server/data/config/admin/descriptors/config_room.txt +4 -4
- data/lib/rubyfox/server/data/config/admin/descriptors/config_server.txt +46 -98
- data/lib/rubyfox/server/data/config/admin/descriptors/config_zone.txt +3 -3
- data/lib/rubyfox/server/data/config/admin/descriptors/runtime_user.txt +8 -1
- data/lib/rubyfox/server/data/config/core.xml +2 -2
- data/lib/rubyfox/server/data/config/server.xml +5 -12
- data/lib/rubyfox/server/data/data/bannedusers/users.bin +0 -0
- data/lib/rubyfox/server/data/extensions/pyTest/Simple.py +1 -1
- data/lib/rubyfox/server/data/lib/cachedir/packages/charsets.pkc +0 -0
- data/lib/rubyfox/server/data/lib/cachedir/packages/cldrdata.pkc +0 -0
- data/lib/rubyfox/server/data/lib/cachedir/packages/dnsns.pkc +0 -0
- data/lib/rubyfox/server/data/lib/cachedir/packages/jaccess.pkc +0 -0
- data/lib/rubyfox/server/data/lib/cachedir/packages/javax.mail.glassfish-1.4.1.v201005082020.pkc +0 -0
- data/lib/rubyfox/server/data/lib/cachedir/packages/javax.transaction-api-1.2.pkc +0 -0
- data/lib/rubyfox/server/data/lib/cachedir/packages/jce.pkc +0 -0
- data/lib/rubyfox/server/data/lib/cachedir/packages/jetty-annotations-9.3.11.v20160721.pkc +0 -0
- data/lib/rubyfox/server/data/lib/cachedir/packages/jetty-deploy-9.3.11.v20160721.pkc +0 -0
- data/lib/rubyfox/server/data/lib/cachedir/packages/jetty-http-9.3.11.v20160721.pkc +0 -0
- data/lib/rubyfox/server/data/lib/cachedir/packages/jetty-io-9.3.11.v20160721.pkc +0 -0
- data/lib/rubyfox/server/data/lib/cachedir/packages/jetty-jndi-9.3.11.v20160721.pkc +0 -0
- data/lib/rubyfox/server/data/lib/cachedir/packages/jetty-plus-9.3.11.v20160721.pkc +0 -0
- data/lib/rubyfox/server/data/lib/cachedir/packages/jetty-schemas-3.1.pkc +0 -0
- data/lib/rubyfox/server/data/lib/cachedir/packages/jetty-security-9.3.11.v20160721.pkc +0 -0
- data/lib/rubyfox/server/data/lib/cachedir/packages/jetty-server-9.3.11.v20160721.pkc +0 -0
- data/lib/rubyfox/server/data/lib/cachedir/packages/jetty-servlet-9.3.11.v20160721.pkc +0 -0
- data/lib/rubyfox/server/data/lib/cachedir/packages/jetty-util-9.3.11.v20160721.pkc +0 -0
- data/lib/rubyfox/server/data/lib/cachedir/packages/jetty-webapp-9.3.11.v20160721.pkc +0 -0
- data/lib/rubyfox/server/data/lib/cachedir/packages/jetty-xml-9.3.11.v20160721.pkc +0 -0
- data/lib/rubyfox/server/data/lib/cachedir/packages/jfr.pkc +0 -0
- data/lib/rubyfox/server/data/lib/cachedir/packages/jfxrt.pkc +0 -0
- data/lib/rubyfox/server/data/lib/cachedir/packages/jsse.pkc +0 -0
- data/lib/rubyfox/server/data/lib/cachedir/packages/localedata.pkc +0 -0
- data/lib/rubyfox/server/data/lib/cachedir/packages/nashorn.pkc +0 -0
- data/lib/rubyfox/server/data/lib/cachedir/packages/packages.idx +0 -0
- data/lib/rubyfox/server/data/lib/cachedir/packages/resources.pkc +0 -0
- data/lib/rubyfox/server/data/lib/cachedir/packages/rt.pkc +0 -0
- data/lib/rubyfox/server/data/lib/cachedir/packages/servlet-api-3.1.pkc +0 -0
- data/lib/rubyfox/server/data/lib/cachedir/packages/sunec.pkc +0 -0
- data/lib/rubyfox/server/data/lib/cachedir/packages/sunjce_provider.pkc +0 -0
- data/lib/rubyfox/server/data/lib/cachedir/packages/sunpkcs11.pkc +0 -0
- data/lib/rubyfox/server/data/lib/cachedir/packages/zipfs.pkc +0 -0
- data/lib/rubyfox/server/data/lib/commons-collections-3.2.2.jar +0 -0
- data/lib/rubyfox/server/data/lib/jetty/etc/jetty.xml +37 -0
- data/lib/rubyfox/server/data/lib/js/JSApi.js +1298 -0
- data/lib/rubyfox/server/data/lib/js/LibApi.js +2046 -0
- data/lib/rubyfox/server/data/lib/js/LibUtil.js +22 -0
- data/lib/rubyfox/server/data/lib/logs-analysis-app.jar +0 -0
- data/lib/rubyfox/server/data/lib/sfs2x-admin.jar +0 -0
- data/lib/rubyfox/server/data/lib/sfs2x-core.jar +0 -0
- data/lib/rubyfox/server/data/lib/sfs2x.jar +0 -0
- data/lib/rubyfox/server/data/sfs2x-service +3 -3
- data/lib/rubyfox/server/data/sfs2x.sh +1 -1
- data/lib/rubyfox/server/data/www/root/admin/AdminTool.swf +0 -0
- data/lib/rubyfox/server/data/www/root/admin/ReleaseNotes.txt +8 -0
- data/lib/rubyfox/server/data/www/root/admin/index.html +6 -6
- data/lib/rubyfox/server/data/www/root/admin/modules/Analytics.swf +0 -0
- data/lib/rubyfox/server/data/www/root/admin/modules/BanManager.swf +0 -0
- data/lib/rubyfox/server/data/www/root/admin/modules/BlueBoxMonitor.swf +0 -0
- data/lib/rubyfox/server/data/www/root/admin/modules/Console.swf +0 -0
- data/lib/rubyfox/server/data/www/root/admin/modules/Dashboard.swf +0 -0
- data/lib/rubyfox/server/data/www/root/admin/modules/ExtensionManager.swf +0 -0
- data/lib/rubyfox/server/data/www/root/admin/modules/LicenseManager.swf +0 -0
- data/lib/rubyfox/server/data/www/root/admin/modules/LogViewer.swf +0 -0
- data/lib/rubyfox/server/data/www/root/admin/modules/ServerConfigurator.swf +0 -0
- data/lib/rubyfox/server/data/www/root/admin/modules/ZoneConfigurator.swf +0 -0
- data/lib/rubyfox/server/data/www/root/admin/modules/ZoneMonitor.swf +0 -0
- data/lib/rubyfox/server/data/www/sfs2x-ws.war +0 -0
- data/lib/rubyfox/server/data/zones/BasicExamples.zone.xml +147 -0
- data/lib/rubyfox/server/version.rb +1 -1
- metadata +42 -7
- data/lib/rubyfox/server/data/lib/commons-collections-3.2.1.jar +0 -0
- data/lib/rubyfox/server/data/lib/js.jar +0 -0
- data/lib/rubyfox/server/data/lib/netty-3.9.0.Final.jar +0 -0
@@ -0,0 +1,1298 @@
|
|
1
|
+
/*
|
2
|
+
* -----------------------------------------------
|
3
|
+
* Server-side Javascript Extension API
|
4
|
+
* @ver 1.0.0
|
5
|
+
* @since SFS2X 2.13
|
6
|
+
* -----------------------------------------------
|
7
|
+
* (c) copyright 2009-2017 GOTOANDPLAY snc
|
8
|
+
*/
|
9
|
+
|
10
|
+
$$API_LIB_PATH = 'lib/js/';
|
11
|
+
|
12
|
+
//--- Import SFS2X names from Java scope ---------------------------------------
|
13
|
+
|
14
|
+
var $$SfsInstance = com.smartfoxserver.v2.SmartFoxServer.getInstance();
|
15
|
+
var $$Helper = com.smartfoxserver.v2.extensions.js.JSHelper;
|
16
|
+
var $$RequestHandlers = new java.util.concurrent.ConcurrentHashMap();
|
17
|
+
var $$EventHandlers = new java.util.concurrent.ConcurrentHashMap();
|
18
|
+
var SFSEventType = com.smartfoxserver.v2.core.SFSEventType;
|
19
|
+
var SFSEventParam = com.smartfoxserver.v2.core.SFSEventParam;
|
20
|
+
|
21
|
+
// --- Import API modules ------------------------------------------------------
|
22
|
+
|
23
|
+
load($$API_LIB_PATH + 'LibApi.js');
|
24
|
+
load($$API_LIB_PATH + 'LibUtil.js');
|
25
|
+
|
26
|
+
// --- Global classes from Java scope ------------------------------------------
|
27
|
+
|
28
|
+
/**
|
29
|
+
* Creates a new <em>SFSObject</em> instance.
|
30
|
+
*
|
31
|
+
* @class
|
32
|
+
* <img src="java-icon.png"></img><br>
|
33
|
+
* <em>SFSObject</em> and <em>SFSArray</em> classes represent a platform-neutral, high level Java objects that abstract the data transport between client and server.
|
34
|
+
* They are used to respectively represent data in form of a map and a list; they can be nested and transport many different data types.</p>
|
35
|
+
*
|
36
|
+
* <p>These objects provide high speed serialization using the default SmartFoxServer binary protocol and the types distinction grants a fine-grained size control of data sent over the network.</p>
|
37
|
+
*
|
38
|
+
* <p>The following is a list of types supported by the <em>SFSObject</em> class:</p>
|
39
|
+
* <ul>
|
40
|
+
* <li>null</li>
|
41
|
+
* <li>boolean</li>
|
42
|
+
* <li>byte (8 bit integer)</li>
|
43
|
+
* <li>short (16 bit integer)</li>
|
44
|
+
* <li>int (32 bit integer)</li>
|
45
|
+
* <li>long (64 bit integer)</li>
|
46
|
+
* <li>float (32 bit floating point number)</li>
|
47
|
+
* <li>double (64 bit double precision number)</li>
|
48
|
+
* <li>utf-string (UTF-8 encoded string, with length up to 32 KBytes)</li>
|
49
|
+
* <li>text (UTF-8 encoded string, with length up to 2 GBytes)</li>
|
50
|
+
* <li>boolean array</li>
|
51
|
+
* <li>byte array</li>
|
52
|
+
* <li>short array</li>
|
53
|
+
* <li>int array</li>
|
54
|
+
* <li>long array</li>
|
55
|
+
* <li>float array</li>
|
56
|
+
* <li>double array</li>
|
57
|
+
* <li>utf-string array</li>
|
58
|
+
* <li>SFSObject</li>
|
59
|
+
* <li>SFSArray</li>
|
60
|
+
* </ul>
|
61
|
+
*
|
62
|
+
* <p><em>SFSObjects</em> and <em>SFSArrays</em> can be nested to create complex data structures.</p>
|
63
|
+
*
|
64
|
+
* <h4>Notes</h4>
|
65
|
+
* <ul>
|
66
|
+
* <li>For members of the <em>SFSObject</em> class, please [refer to its Javadoc]{@link http://docs2x.smartfoxserver.com/api-docs/javadoc/server/com/smartfoxserver/v2/entities/data/SFSObject.html}.</li>
|
67
|
+
* <li>Strings are handled via UTF-8 encoding, to support all languages and character sets.</li>
|
68
|
+
* <li>In JavaScript, long integer numbers are limited to [Number.MAX_SAFE_INTEGER]{@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number/MAX_SAFE_INTEGER} (positive and negative, inclusive).
|
69
|
+
* This is inconsistent with the max and min Long values available in Java, which are down to <code>-2^63</code> and up to <code>(2^63)-1</code>.</li>
|
70
|
+
* </ul>
|
71
|
+
*
|
72
|
+
* <h4>See also</h4>
|
73
|
+
* <ul>
|
74
|
+
* <li>{@link SFSArray} class</li>
|
75
|
+
* <li><img src="java-icon-small.png"></img> [SFSObject]{@link http://docs2x.smartfoxserver.com/api-docs/javadoc/server/com/smartfoxserver/v2/entities/data/SFSObject.html} class</li>
|
76
|
+
* </ul>
|
77
|
+
*
|
78
|
+
* @example
|
79
|
+
* <caption>In this simple example we create a new SFSObject to send the data of a combat vehicle to clients in a multiplayer game.<br>
|
80
|
+
* We use a single Byte (signed 8-bit) to send the small integer value representing the vehicle's id, a Short (signed 16-bit) for the larger health value and an array of Int to transmit the x/y position of the vehicle.</caption>
|
81
|
+
* var sfso = new SFSObject();
|
82
|
+
* sfso.putByte("id", 10); // the vehicle id
|
83
|
+
* sfso.putShort("health", 5000); // the vehicle current health
|
84
|
+
* sfso.putIntArray("pos", [120,150]); // the vehicle x,y position on the terrain, as a nested array
|
85
|
+
* sfso.putUtfString("name", "Hurricane"); // the vehicle name
|
86
|
+
*/
|
87
|
+
var SFSObject = Java.type('com.smartfoxserver.v2.extensions.js.SFSObjectJS');
|
88
|
+
|
89
|
+
/**
|
90
|
+
* Creates a new <em>SFSArray</em> instance.
|
91
|
+
*
|
92
|
+
* @class
|
93
|
+
* <img src="java-icon.png"></img><br>
|
94
|
+
* <em>SFSObject</em> and <em>SFSArray</em> classes represent a platform-neutral, high level Java objects that abstract the data transport between client and server.
|
95
|
+
* They are used to respectively represent data in form of a map and a list; they can be nested and transport many different data types.</p>
|
96
|
+
*
|
97
|
+
* <p>These objects provide high speed serialization using the default SmartFoxServer binary protocol and the types distinction grants a fine-grained size control of data sent over the network.</p>
|
98
|
+
*
|
99
|
+
* <p>The following is a list of types supported by the <em>SFSArray</em> class:</p>
|
100
|
+
* <ul>
|
101
|
+
* <li>null</li>
|
102
|
+
* <li>boolean</li>
|
103
|
+
* <li>byte (8 bit integer)</li>
|
104
|
+
* <li>short (16 bit integer)</li>
|
105
|
+
* <li>int (32 bit integer)</li>
|
106
|
+
* <li>long (64 bit integer)</li>
|
107
|
+
* <li>float (32 bit floating point number)</li>
|
108
|
+
* <li>double (64 bit double precision number)</li>
|
109
|
+
* <li>utf-string (UTF-8 encoded string, with length up to 32 KBytes)</li>
|
110
|
+
* <li>text (UTF-8 encoded string, with length up to 2 GBytes)</li>
|
111
|
+
* <li>boolean array</li>
|
112
|
+
* <li>byte array</li>
|
113
|
+
* <li>short array</li>
|
114
|
+
* <li>int array</li>
|
115
|
+
* <li>long array</li>
|
116
|
+
* <li>float array</li>
|
117
|
+
* <li>double array</li>
|
118
|
+
* <li>utf-string array</li>
|
119
|
+
* <li>SFSObject</li>
|
120
|
+
* <li>SFSArray</li>
|
121
|
+
* </ul>
|
122
|
+
*
|
123
|
+
* <p><em>SFSObjects</em> and <em>SFSArrays</em> can be nested to create complex data structures.<br>
|
124
|
+
* Using a <em>SFSArray</em> can help to further reduce to a minimum the amount of bytes sent, because it avoids the overhead of key names for each item like in a <em>SFSObject</em>.</p>
|
125
|
+
*
|
126
|
+
* <h4>Notes</h4>
|
127
|
+
* <ul>
|
128
|
+
* <li>For members of the <em>SFSArray</em> class, please [refer to its Javadoc]{@link http://docs2x.smartfoxserver.com/api-docs/javadoc/server/com/smartfoxserver/v2/entities/data/SFSArray.html}.</li>
|
129
|
+
* <li>Strings are handled via UTF-8 encoding, to support all languages and character sets.</li>
|
130
|
+
* <li>In JavaScript, long integer numbers are limited to [Number.MAX_SAFE_INTEGER]{@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number/MAX_SAFE_INTEGER} (positive and negative, inclusive).
|
131
|
+
* This is inconsistent with the max and min Long values available in Java, which are down to <code>-2^63</code> and up to <code>(2^63)-1</code>.</li>
|
132
|
+
* </ul>
|
133
|
+
*
|
134
|
+
* <h4>See also</h4>
|
135
|
+
* <ul>
|
136
|
+
* <li>{@link SFSObject} class</li>
|
137
|
+
* <li><img src="java-icon-small.png"></img> [SFSArray]{@link http://docs2x.smartfoxserver.com/api-docs/javadoc/server/com/smartfoxserver/v2/entities/data/SFSArray.html} class</li>
|
138
|
+
* </ul>
|
139
|
+
*
|
140
|
+
* @example
|
141
|
+
* <caption>In this simple example we create a new SFSArray to send the data of a combat vehicle to clients in a multiplayer game.<br>
|
142
|
+
* We use a single Byte (signed 8-bit) to send the small integer value representing the vehicle's id, a Short (signed 16-bit) for the larger health value and an array of Int to transmit the x/y position of the vehicle.</caption>
|
143
|
+
* var sfsa = new SFSArray();
|
144
|
+
* sfsa.addByte(10); // the vehicle id
|
145
|
+
* sfsa.addShort(5000); // the vehicle current health
|
146
|
+
* sfsa.addIntArray([120,150]); // the vehicle x,y position on the terrain, as a nested array
|
147
|
+
* sfsa.addUtfString("Hurricane"); // the vehicle name
|
148
|
+
*/
|
149
|
+
var SFSArray = Java.type('com.smartfoxserver.v2.extensions.js.SFSArrayJS');
|
150
|
+
|
151
|
+
/**
|
152
|
+
* Creates a new <em>CreateRoomSettings</em> instance.
|
153
|
+
*
|
154
|
+
* @class
|
155
|
+
* <img src="java-icon.png"></img><br>
|
156
|
+
* The <em>CreateRoomSettings</em> class allows to configure how a new Room will work under many different aspects, from its size to the events it can fire, permissions and a lot more.
|
157
|
+
*
|
158
|
+
* <h4>Basic settings</h4>
|
159
|
+
* <p>A minimal Room configuration should always contain the following parameters:</p>
|
160
|
+
* <ul>
|
161
|
+
* <li><strong>name</strong>: the name of the Room, must be unique</li>
|
162
|
+
* <li><strong>password</strong>: (optional) the password to enter to join the Room, for private Rooms</li>
|
163
|
+
* <li><strong>maxUsers</strong>: the maximum number of users allowed to join the Room</li>
|
164
|
+
* <li><strong>maxVariablesAllowed</strong>: the maximum number of Room Variables allowed in the Room</li>
|
165
|
+
* <li><strong>isGame</strong>: (optional, default <code>false</code>) a flag to indicate if the Room is going to be used for games (it is a "Game Room")</li>
|
166
|
+
* <li><strong>maxSpectators</strong>: (optional) in a Game Room, the maximum number of spectators allowed to join it</li>
|
167
|
+
* </ul>
|
168
|
+
*
|
169
|
+
* <h4>More settings</h3
|
170
|
+
* <p>The following settings help defining other important features of a Room:</p>
|
171
|
+
* <ul>
|
172
|
+
* <li><strong>groupId</strong>: the name of the Group to which the Room will be assigned</li>
|
173
|
+
* <li><strong>idDynamic</strong>: a flag indicating that the Room is dynamic</li>
|
174
|
+
* <li><strong>isHidden</strong>: a flag indicating if the Room should concealed from the Room List sent to clients</li>
|
175
|
+
* <li><strong>autoRemoveMode</strong>: a {@link SFSRoomRemoveMode} value to configure when the Room, if dynamic, should be destroyed</li>
|
176
|
+
* <li><strong>roomVariables</strong>: an array of {@link SFSRoomVariable} objects that will be added to the Room upon creation</li>
|
177
|
+
* <li><strong>extension</strong>: a {@link RoomExtensionSettings} instance defining the server side Extension to be dynamically attached to the Room, to add custom logic for games and applications</li>
|
178
|
+
* </ul>
|
179
|
+
*
|
180
|
+
* <h4>Advanced settings</h4>
|
181
|
+
* <p>The following settings help defines the most advanced features of a Room:</p>
|
182
|
+
* <ul>
|
183
|
+
* <li><strong>roomSettings</strong>: an {@link EnumSet} of {@link SFSRoomSettings} values that specify permissions and events used by the Room</li>
|
184
|
+
* <li><strong>useWordsFilter</strong>: a flag to indicate if the bad words filter is enable on the Room</li>
|
185
|
+
* <li><strong>customPlayerIdGeneratorClass</strong>: a custom class that handles the generation of player id(s) for Game Rooms</li>
|
186
|
+
* <li><strong>allowOwnerOnlyInvitation</strong>: a flag indicating if the Room's owner only is allowed to send invitations to join the Room to other users</li>
|
187
|
+
* <li><strong>roomProperties</strong>: a map of custom, server side only properties attached to the Room</li>
|
188
|
+
* </ul>
|
189
|
+
*
|
190
|
+
* <h4>Notes</h4>
|
191
|
+
* <ul>
|
192
|
+
* <li>For members of the <em>CreateRoomSettings</em> class, please [refer to its Javadoc]{@link http://docs2x.smartfoxserver.com/api-docs/javadoc/server/com/smartfoxserver/v2/api/CreateRoomSettings.html}.</li>
|
193
|
+
* </ul>
|
194
|
+
*
|
195
|
+
* <h4>See also</h4>
|
196
|
+
* <ul>
|
197
|
+
* <li>{@link SFSApi#createRoom} method</li>
|
198
|
+
* <li>{@link SFSRoomRemoveMode} enum</li>
|
199
|
+
* <li>{@link SFSRoomVariable} class</li>
|
200
|
+
* <li>{@link SFSRoomSettings} enum</li>
|
201
|
+
* <li><img src="java-icon-small.png"></img> [CreateRoomSettings]{@link http://docs2x.smartfoxserver.com/api-docs/javadoc/server/com/smartfoxserver/v2/api/CreateRoomSettings.html} class</li>
|
202
|
+
* </ul>
|
203
|
+
*/
|
204
|
+
var CreateRoomSettings = Java.type('com.smartfoxserver.v2.api.CreateRoomSettings');
|
205
|
+
|
206
|
+
/**
|
207
|
+
* Creates a new <em>RoomExtensionSettings</em> instance to be passed to the <em>CreateRoomSettings</em> class.
|
208
|
+
*
|
209
|
+
* @param {string} id The id of the Extension, corresponding to the Extension folder name.
|
210
|
+
* @param {string} className The Extension main JavaScript file or Java class.
|
211
|
+
*
|
212
|
+
* @class
|
213
|
+
* <img src="java-icon.png"></img><br>
|
214
|
+
* The <em>RoomExtensionSettings</em> class defines the server side Extension to be dynamically attached to a Room, to add custom logic for games and applications.
|
215
|
+
*
|
216
|
+
* <h4>Notes</h4>
|
217
|
+
* <ul>
|
218
|
+
* <li>For members of the <em>RoomExtensionSettings</em> class, please [refer to its Javadoc]{@link http://docs2x.smartfoxserver.com/api-docs/javadoc/server/com/smartfoxserver/v2/api/CreateRoomSettings.RoomExtensionSettings.html}.</li>
|
219
|
+
* </ul>
|
220
|
+
*
|
221
|
+
* <h4>See also</h4>
|
222
|
+
* <ul>
|
223
|
+
* <li>{@link CreateRoomSettings} class</li>
|
224
|
+
* <li><img src="java-icon-small.png"></img> [CreateRoomSettings.RoomExtensionSettings]{@link http://docs2x.smartfoxserver.com/api-docs/javadoc/server/com/smartfoxserver/v2/api/CreateRoomSettings.RoomExtensionSettings.html} class</li>
|
225
|
+
* </ul>
|
226
|
+
*/
|
227
|
+
var RoomExtensionSettings = Java.type('com.smartfoxserver.v2.api.CreateRoomSettings.RoomExtensionSettings');
|
228
|
+
|
229
|
+
/**
|
230
|
+
* Creates a new <em>CreateSFSGameSettings</em> instance.
|
231
|
+
*
|
232
|
+
* @class
|
233
|
+
* <img src="java-icon.png"></img><br>
|
234
|
+
* The <em>CreateSFSGameSettings</em> class extends the basic [CreateRoomSettings]{@link CreateRoomSettings} class providing all the settings required to create an <strong>SFSGame</strong>.
|
235
|
+
*
|
236
|
+
* <p>The SFSGame is a specialized Room, part of the SmartFoxServer 2X Game API. This provides many advanced features such as player matching, game invitations, public and private games, quick game joining, etc.<br>
|
237
|
+
* For an introduction to the SFSGame features, see the <img src="java-icon-small.png"></img> [SFSGame]{@link http://docs2x.smartfoxserver.com/api-docs/javadoc/server/com/smartfoxserver/v2/game/SFSGame.html} class documentation.</p>
|
238
|
+
*
|
239
|
+
* <h4>SFSGame settings</h4>
|
240
|
+
* <p>The following parameters define the special SFSGame features:</p>
|
241
|
+
* <ul>
|
242
|
+
* <li><strong>isGamePublic</strong>: a flag indicating if the game is public or private. A public game can be joined by any player whose variables match the SFSGame Player Match Expression; private games are based on invitations sent by the SFSGame creator</li>
|
243
|
+
* <li><strong>minPlayersToStartGame</strong>: the minimum number of players to start the game</li>
|
244
|
+
* <li><strong>invitedPlayers</strong>: (private games only) a list of players to be invited to play the game</li>
|
245
|
+
* <li><strong>searchableRooms</strong>: (private games only) a list of Rooms where the Game API should search for more players to invite. The API will look for more players if the number of people invited is smaller than the <em>minPlayersToStartGame</em> setting. This way friends can be added to the game and the system will find the missing players to start it</li>
|
246
|
+
* <li><strong>leaveLastJoinedRoom</strong>: auto-remove players from their previous Room/s after successfully joining the new SFSGame</li>
|
247
|
+
* <li><strong>playerMatchExpression</strong>: an expression to match players willing to play the game (by default no expression is used)</li>
|
248
|
+
* <li><strong>spectatorMatchExpression</strong>: an expression to match spectators willing to attend to the game (by default no expression is used)</li>
|
249
|
+
* <li><strong>invitationExpiryTime</strong>: the amount of time allowed for users to accept or refuse an invitation to play a game</li>
|
250
|
+
* <li><strong>invitationParameters</strong>: optional custom parameters attached to the invitation. For example these could provide details about the inviter, the game, an invitation message, etc</li>
|
251
|
+
* <li><strong>notifyGameStartedViaRoomVariable</strong>: automatically update a reserved Room Variable to signal that the game is started/stopped. The Room Variable uses the <em>global</em> setting to be broadcast outside of the Room; this can be used on the client side to show the game state in the available games list</li>
|
252
|
+
* </ul>
|
253
|
+
*
|
254
|
+
* <h4>Notes</h4>
|
255
|
+
* <ul>
|
256
|
+
* <li>For members of the <em>CreateSFSGameSettings</em> class, please [refer to its Javadoc]{@link http://docs2x.smartfoxserver.com/api-docs/javadoc/server/com/smartfoxserver/v2/game/CreateSFSGameSettings.html}.</li>
|
257
|
+
* </ul>
|
258
|
+
*
|
259
|
+
* <h4>See also</h4>
|
260
|
+
* <ul>
|
261
|
+
* <li>{@link GameApi#createGame} method</li>
|
262
|
+
* <li>{@link MatchExpression} class</li>
|
263
|
+
* <li><img src="java-icon-small.png"></img> [CreateSFSGameSettings]{@link http://docs2x.smartfoxserver.com/api-docs/javadoc/server/com/smartfoxserver/v2/game/CreateSFSGameSettings.html} class</li>
|
264
|
+
* </ul>
|
265
|
+
*
|
266
|
+
* @extends CreateRoomSettings
|
267
|
+
*/
|
268
|
+
var CreateSFSGameSettings = Java.type('com.smartfoxserver.v2.game.CreateSFSGameSettings');
|
269
|
+
|
270
|
+
/**
|
271
|
+
* Creates a new <em>CreateMMORoomSettings</em> instance.
|
272
|
+
*
|
273
|
+
* @class
|
274
|
+
* <img src="java-icon.png"></img><br>
|
275
|
+
* The <em>CreateMMORoomSettings</em> class extends the basic [CreateRoomSettings]{@link CreateRoomSettings} class adding new functionalities that are unique to an MMORoom.
|
276
|
+
*
|
277
|
+
* <p>For a full discussion of the MMORoom features, see the <img src="java-icon-small.png"></img> [MMORoom]{@link http://docs2x.smartfoxserver.com/api-docs/javadoc/server/com/smartfoxserver/v2/mmo/MMORoom.html} class documentation.</p>
|
278
|
+
*
|
279
|
+
* <h4>MMORoom settings</h4>
|
280
|
+
* <p>The following parameters define the MMORoom features:</p>
|
281
|
+
* <ul>
|
282
|
+
* <li><strong>defaultAOI</strong>: a <img src="java-icon-small.png"></img> [Vec3D]{@link http://docs2x.smartfoxserver.com/api-docs/javadoc/server/com/smartfoxserver/v2/mmo/Vec3D.html} instance setting the 2D/3D positional range within which events are broadcast</li>
|
283
|
+
* <li><strong>mapLimits</strong>: (optional) a {@link MapLimits} instance setting the upper and lower limits (along the X,Y,Z axes) of the virtual world represented by the MMORoom</li>
|
284
|
+
* <li><strong>userMaxLimboSeconds</strong>: (optional, default <code>50</code>) the number of seconds a user can remain in the MMORoom without setting his initial position</li>
|
285
|
+
* <li><strong>proximityListUpdateMillis</strong>: (optional, default <code>250</code>) the number of milliseconds between each proximity list update event sent to clients</li>
|
286
|
+
* <li><strong>sendAOIEntryPoint</strong>: (optional, default <code>true</code>) a flag to indicate if the entry position of a user inside another player's Area of Interest should be sent in the proximity list update event</li>
|
287
|
+
* </ul>
|
288
|
+
*
|
289
|
+
* <h4>Notes</h4>
|
290
|
+
* <ul>
|
291
|
+
* <li>Coordinates in <em>defaultAOI</em> and <em>mapLimits</em> settings must be passed as a <img src="java-icon-small.png"></img> [Vec3D]{@link http://docs2x.smartfoxserver.com/api-docs/javadoc/server/com/smartfoxserver/v2/mmo/Vec3D.html} instances, but this class is not available in JavaScript due to constructor overloading in Java.
|
292
|
+
* You can use the {@link Vectors.newVec3D} helper method to generate a <em>Vec3D</em> object as appropriate.</li>
|
293
|
+
* <li>For members of the <em>CreateMMORoomSettings</em> class, please [refer to its Javadoc]{@link http://docs2x.smartfoxserver.com/api-docs/javadoc/server/com/smartfoxserver/v2/mmo/CreateMMORoomSettings.html}.</li>
|
294
|
+
* </ul>
|
295
|
+
*
|
296
|
+
* <h4>See also</h4>
|
297
|
+
* <ul>
|
298
|
+
* <li>{@link SFSApi#createRoom} method</li>
|
299
|
+
* <li><img src="java-icon-small.png"></img> [CreateSFSGameSettings]{@link http://docs2x.smartfoxserver.com/api-docs/javadoc/server/com/smartfoxserver/v2/mmo/CreateMMORoomSettings.html} class</li>
|
300
|
+
* </ul>
|
301
|
+
*
|
302
|
+
* @extends CreateRoomSettings
|
303
|
+
*/
|
304
|
+
var CreateMMORoomSettings = Java.type('com.smartfoxserver.v2.mmo.CreateMMORoomSettings');
|
305
|
+
|
306
|
+
/**
|
307
|
+
* Creates a new <em>MapLimits</em> instance to be passed to the <em>CreateMMORoomSettings</em> class.
|
308
|
+
*
|
309
|
+
* <p>The <em>MapLimits</em> parameters must be passed as a <img src="java-icon-small.png"></img> [Vec3D]{@link http://docs2x.smartfoxserver.com/api-docs/javadoc/server/com/smartfoxserver/v2/mmo/Vec3D.html} instances, but this class is not available in JavaScript due to constructor overloading in Java.
|
310
|
+
* You can use the {@link Vectors.newVec3D} helper method to generate a <em>Vec3D</em> object as appropriate.</p>
|
311
|
+
*
|
312
|
+
* @param {Vec3D} low The lower coordinate limits.
|
313
|
+
* @param {Vec3D} high The higher coordinate limits.
|
314
|
+
*
|
315
|
+
* @class
|
316
|
+
* <img src="java-icon.png"></img><br>
|
317
|
+
* The <em>MapLimits</em> class is a data container that holds the upper and lower limits (along the X,Y,Z axes) of the virtual world represented by an MMORoom.
|
318
|
+
*
|
319
|
+
* <h4>Notes</h4>
|
320
|
+
* <ul>
|
321
|
+
* <li>For members of the <em>MapLimits</em> class, please [refer to its Javadoc]{@link http://docs2x.smartfoxserver.com/api-docs/javadoc/server/com/smartfoxserver/v2/mmo/CreateMMORoomSettings.MapLimits.html}.</li>
|
322
|
+
* </ul>
|
323
|
+
*
|
324
|
+
* <h4>See also</h4>
|
325
|
+
* <ul>
|
326
|
+
* <li>{@link CreateMMORoomSettings} class</li>
|
327
|
+
* <li><img src="java-icon-small.png"></img> [CreateMMORoomSettings.MapLimits]{@link http://docs2x.smartfoxserver.com/api-docs/javadoc/server/com/smartfoxserver/v2/mmo/CreateMMORoomSettings.MapLimits.html} class</li>
|
328
|
+
* </ul>
|
329
|
+
*/
|
330
|
+
var MapLimits = Java.type('com.smartfoxserver.v2.mmo.CreateMMORoomSettings.MapLimits');
|
331
|
+
|
332
|
+
/**
|
333
|
+
* Creates a new <em>SFSUserVariable</em> instance.
|
334
|
+
*
|
335
|
+
* <p>Although the third parameter is optional, it is strongly recommended to use it. The reason is type autodetection of numbers (being integers or double precision numbers)
|
336
|
+
* may fail in some corner cases (for example <code>n = Math.floor(100.0 - 99.0)</code> will be treated as a double instead of an integer as expected).</p>
|
337
|
+
*
|
338
|
+
* @param {string} name The name of the User Variable.
|
339
|
+
* @param {boolean|number|string|SFSObject|SFSArray} value The value of the User Variable; it can also be <code>null</code>.
|
340
|
+
* @param {VariableType} [type=null] The type of the User Variable's value, among those listed in the <em>VariableType</em> enum; if <code>null</code>, type is autodetected.
|
341
|
+
*
|
342
|
+
* @class
|
343
|
+
* <img src="java-icon.png"></img><br>
|
344
|
+
* The <em>SFSUserVariable</em> class represents a User Variable, a custom value attached to each User object that gets automatically updated between client and server on every change.
|
345
|
+
*
|
346
|
+
* <p>User Variables are particularly useful to assign any custom data to a user, such as his current in-game status, profile data, scoring, etc.<br>
|
347
|
+
* They support basic data types and nested complex objects:</p>
|
348
|
+
* <ul>
|
349
|
+
* <li>null</li>
|
350
|
+
* <li>boolean</li>
|
351
|
+
* <li>int (32 bit integer)</li>
|
352
|
+
* <li>double (64 bit double precision number)</li>
|
353
|
+
* <li>utf-string (UTF-8 encoded string, with length up to 32 KBytes)</li>
|
354
|
+
* <li>SFSObject</li>
|
355
|
+
* <li>SFSArray</li>
|
356
|
+
* </ul>
|
357
|
+
*
|
358
|
+
* <p>User Variables are visibile to all users in the same Room. In other words all users in the same Room are able to read all other players' variables with the exclusion of those marked as hidden or private:</p>
|
359
|
+
* <ul>
|
360
|
+
* <li>an <strong>hidden</strong> User Variable is only available on the server-side and never transmitted to other clients, including its owner;</li>
|
361
|
+
* <li>a <strong>private</strong> User Variable is only visible to its owner and never transmitted to other clients, including those in the same Room of the owner.</li>
|
362
|
+
* </ul>
|
363
|
+
*
|
364
|
+
* <h4>Notes</h4>
|
365
|
+
* <ul>
|
366
|
+
* <li>For members of the <em>SFSUserVariable</em> class, please [refer to its Javadoc]{@link http://docs2x.smartfoxserver.com/api-docs/javadoc/server/com/smartfoxserver/v2/entities/variables/SFSUserVariable.html}.</li>
|
367
|
+
* </ul>
|
368
|
+
*
|
369
|
+
* <h4>See also</h4>
|
370
|
+
* <ul>
|
371
|
+
* <li>{@link SFSApi#setUserVariables} method</li>
|
372
|
+
* <li><img src="java-icon-small.png"></img> [SFSUserVariable]{@link http://docs2x.smartfoxserver.com/api-docs/javadoc/server/com/smartfoxserver/v2/entities/variables/SFSUserVariable.html} class</li>
|
373
|
+
* </ul>
|
374
|
+
*/
|
375
|
+
var SFSUserVariable = Java.type('com.smartfoxserver.v2.extensions.js.SFSUserVariableJS');
|
376
|
+
|
377
|
+
/**
|
378
|
+
* Creates a new <em>SFSRoomVariable</em> instance.
|
379
|
+
*
|
380
|
+
* <p>Although the third parameter is optional, it is strongly recommended to use it. The reason is type autodetection of numbers (being integers or double precision numbers)
|
381
|
+
* may fail in some corner cases (for example <code>n1 = Math.floor(100.0 - 99.0)</code> will be treated as a double instead of an integer as expected).</p>
|
382
|
+
*
|
383
|
+
* @param {string} name The name of the Room Variable.
|
384
|
+
* @param {boolean|number|string|SFSObject|SFSArray} value The value of the Room Variable; it can also be <code>null</code>.
|
385
|
+
* @param {VariableType} [type=null] The type of the Room Variable's value, among those listed in the <em>VariableType</em> enum; if <code>null</code>, type is autodetected.
|
386
|
+
*
|
387
|
+
* @class
|
388
|
+
* <img src="java-icon.png"></img><br>
|
389
|
+
* The <em>SFSRoomVariable</em> class represents a Room Variable, a custom value attached to a Room object that gets automatically updated between client and server on every change.
|
390
|
+
*
|
391
|
+
* <p>Room Variables are particularly useful to "attach" any custom data to a Room, such as the current game status in a game Room, the topic in chat Room, other Room-specific properties, etc.<br>
|
392
|
+
* They support basic data types and nested complex objects:</p>
|
393
|
+
* <ul>
|
394
|
+
* <li>null</li>
|
395
|
+
* <li>boolean</li>
|
396
|
+
* <li>int (32 bit integer)</li>
|
397
|
+
* <li>double (64 bit double precision number)</li>
|
398
|
+
* <li>utf-string (UTF-8 encoded string, with length up to 32 KBytes)</li>
|
399
|
+
* <li>SFSObject</li>
|
400
|
+
* <li>SFSArray</li>
|
401
|
+
* </ul>
|
402
|
+
*
|
403
|
+
* <p>Room Variables support a few different flags:</p>
|
404
|
+
* <ul>
|
405
|
+
* <li>a <strong>private</strong> Room Variable can only be modified by its creator;</li>
|
406
|
+
* <li>a <strong>persisten</strong> Room Variable continues to exist even if its creator has left the Room; server-created Room Variables are removed;</li>
|
407
|
+
* <li>a <strong>global</strong> Room Variable change causes an update event to be sent not only to all users in the Room, but also to all users in the Room Group to which the Room belongs;</li>
|
408
|
+
* <li>an <strong>hidden</strong> Room Variable is only available on the server-side and never transmitted to the clients.</li>
|
409
|
+
* </ul>
|
410
|
+
*
|
411
|
+
* <h4>Notes</h4>
|
412
|
+
* <ul>
|
413
|
+
* <li>For members of the <em>SFSRoomVariable</em> class, please [refer to its Javadoc]{@link http://docs2x.smartfoxserver.com/api-docs/javadoc/server/com/smartfoxserver/v2/entities/variables/SFSRoomVariable.html}.</li>
|
414
|
+
* </ul>
|
415
|
+
*
|
416
|
+
* <h4>See also</h4>
|
417
|
+
* <ul>
|
418
|
+
* <li>{@link SFSApi#setRoomVariables} method</li>
|
419
|
+
* <li><img src="java-icon-small.png"></img> [SFSRoomVariable]{@link http://docs2x.smartfoxserver.com/api-docs/javadoc/server/com/smartfoxserver/v2/entities/variables/SFSRoomVariable.html} class</li>
|
420
|
+
* </ul>
|
421
|
+
*/
|
422
|
+
var SFSRoomVariable = Java.type('com.smartfoxserver.v2.extensions.js.SFSRoomVariableJS');
|
423
|
+
|
424
|
+
/**
|
425
|
+
* Creates a new <em>SFSBuddyVariable</em> instance.
|
426
|
+
*
|
427
|
+
* <p>Although the third parameter is optional, it is strongly recommended to use it. The reason is type autodetection of numbers (being integers or double precision numbers)
|
428
|
+
* may fail in some corner cases (for example <code>n1 = Math.floor(100.0 - 99.0)</code> will be treated as a double instead of an integer as expected).</p>
|
429
|
+
*
|
430
|
+
* @param {string} name The name of the Buddy Variable.
|
431
|
+
* @param {boolean|number|string|SFSObject|SFSArray} value The value of the Buddy Variable; it can also be <code>null</code>.
|
432
|
+
* @param {VariableType} [type=null] The type of the Buddy Variable's value, among those listed in the <em>VariableType</em> enum; if <code>null</code>, type is autodetected.
|
433
|
+
*
|
434
|
+
* @class
|
435
|
+
* <img src="java-icon.png"></img><br>
|
436
|
+
* The <em>SFSBuddyVariable</em> class represents a Buddy Variable, a custom value attached to a Buddy in a Buddy List.
|
437
|
+
*
|
438
|
+
* <p>Buddy Variables work with the same principle of the User/Room Variables. The only difference is the logic by which they get propagated to other users: while Room Variables are broadcast to all clients in the same Room, Buddy Variables are sent to all users who have the variable owner in their Buddy Lists.<br>
|
439
|
+
* They support basic data types and nested complex objects:</p>
|
440
|
+
* <ul>
|
441
|
+
* <li>null</li>
|
442
|
+
* <li>boolean</li>
|
443
|
+
* <li>int (32 bit integer)</li>
|
444
|
+
* <li>double (64 bit double precision number)</li>
|
445
|
+
* <li>utf-string (UTF-8 encoded string, with length up to 32 KBytes)</li>
|
446
|
+
* <li>SFSObject</li>
|
447
|
+
* <li>SFSArray</li>
|
448
|
+
* </ul>
|
449
|
+
*
|
450
|
+
* <h4>Notes</h4>
|
451
|
+
* <ul>
|
452
|
+
* <li>For members of the <em>SFSBuddyVariable</em> class, please [refer to its Javadoc]{@link http://docs2x.smartfoxserver.com/api-docs/javadoc/server/com/smartfoxserver/v2/buddylist/SFSBuddyVariable.html}.</li>
|
453
|
+
* <li>Buddy Variables provide a special convention that allows variables to be "seen" by the buddies even if the owner is not online. All variable names starting with a dollar sign ($) will be <strong>persistent</strong> and available at any time whether the owner is online or not.</li>
|
454
|
+
* </ul>
|
455
|
+
*
|
456
|
+
* <h4>See also</h4>
|
457
|
+
* <ul>
|
458
|
+
* <li>{@link BuddyApi#setBuddyVariables} method</li>
|
459
|
+
* <li><img src="java-icon-small.png"></img> [SFSBuddyVariable]{@link http://docs2x.smartfoxserver.com/api-docs/javadoc/server/com/smartfoxserver/v2/buddylist/SFSBuddyVariable.html} class</li>
|
460
|
+
* </ul>
|
461
|
+
*/
|
462
|
+
var SFSBuddyVariable = Java.type('com.smartfoxserver.v2.extensions.js.SFSBuddyVariableJS');
|
463
|
+
|
464
|
+
/**
|
465
|
+
* Creates a new <em>MMOItemVariable</em> instance.
|
466
|
+
*
|
467
|
+
* <p>Although the third parameter is optional, it is strongly recommended to use it. The reason is type autodetection of numbers (being integers or double precision numbers)
|
468
|
+
* may fail in some corner cases (for example <code>n1 = Math.floor(100.0 - 99.0)</code> will be treated as a double instead of an integer as expected).</p>
|
469
|
+
*
|
470
|
+
* @param {string} name The name of the MMOItem Variable.
|
471
|
+
* @param {boolean|number|string|SFSObject|SFSArray} value The value of the MMOItem Variable; it can also be <code>null</code>.
|
472
|
+
* @param {VariableType} [type=null] The type of the MMOItem Variable's value, among those listed in the <em>VariableType</em> enum; if <code>null</code>, type is autodetected.
|
473
|
+
*
|
474
|
+
* @class
|
475
|
+
* <img src="java-icon.png"></img><br>
|
476
|
+
* The <em>MMOItemVariable</em> class represents an MMOItem Variable, a custom value attached to an MMOItem inside an MMORoom.
|
477
|
+
*
|
478
|
+
* <p>MMOItem Variables behave exactly like User Variables, but can be updated or removed on the server side only.<br>
|
479
|
+
* They support basic data types and nested complex objects:</p>
|
480
|
+
* <ul>
|
481
|
+
* <li>null</li>
|
482
|
+
* <li>boolean</li>
|
483
|
+
* <li>int (32 bit integer)</li>
|
484
|
+
* <li>double (64 bit double precision number)</li>
|
485
|
+
* <li>utf-string (UTF-8 encoded string, with length up to 32 KBytes)</li>
|
486
|
+
* <li>SFSObject</li>
|
487
|
+
* <li>SFSArray</li>
|
488
|
+
* </ul>
|
489
|
+
*
|
490
|
+
* <h4>Notes</h4>
|
491
|
+
* <ul>
|
492
|
+
* <li>For members of the <em>MMOItemVariable</em> class, please [refer to its Javadoc]{@link http://docs2x.smartfoxserver.com/api-docs/javadoc/server/com/smartfoxserver/v2/mmo/MMOItemVariable.html}.</li>
|
493
|
+
* </ul>
|
494
|
+
*
|
495
|
+
* <h4>See also</h4>
|
496
|
+
* <ul>
|
497
|
+
* <li>{@link MMOItem}</li>
|
498
|
+
* <li>{@link MMOApi#setMMOItemVariables} method</li>
|
499
|
+
* <li><img src="java-icon-small.png"></img> [MMOItemVariable]{@link http://docs2x.smartfoxserver.com/api-docs/javadoc/server/com/smartfoxserver/v2/mmo/MMOItemVariable.html} class</li>
|
500
|
+
* </ul>
|
501
|
+
*/
|
502
|
+
var MMOItemVariable = Java.type('com.smartfoxserver.v2.extensions.js.MMOItemVariableJS');
|
503
|
+
|
504
|
+
/**
|
505
|
+
* Creates a new <em>MatchExpression</em> instance.
|
506
|
+
*
|
507
|
+
* @param {string} varName The name of the User/Room Variable or one of the properties listed in <em>RoomProperties</em> or <em>UserProperties</em> enums.
|
508
|
+
* @param {BoolMatch|NumberMatch|StringMatch} condition A matching condition among those provided by the <em>BoolMatch</em>, <em>NumberMatch</em> and <em>StringMatch</em> enums.
|
509
|
+
* @param {boolean|number|string} value The value to compare against the User/Room Variable or property during the matching.
|
510
|
+
*
|
511
|
+
* @class
|
512
|
+
* <img src="java-icon.png"></img><br>
|
513
|
+
* The <em>MatchExpression</em> class represents a Match Expression, a querying system to search for Rooms or Users using custom criteria.
|
514
|
+
*
|
515
|
+
* <p>Match Expressions are built like "if" conditions 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.
|
516
|
+
* These expressions are extremely easy to create and concatenate and they can be used for many different filtering operations within the SFS2X framework.</p>
|
517
|
+
*
|
518
|
+
* <h4>Overview</h4>
|
519
|
+
* <p>Match Expressions are made of three elements: a User/Room Variable name or property to query, a match operator expressing the required condition and the value to match the Variable or property against.
|
520
|
+
* Additionally, any number of expressions can be linked together with the logical operators AND and OR, just like in regular "if" expressions.</p>
|
521
|
+
* <p>The search options are not just limited to User/Room Variables names: the Match Expressions engine provides two extra classes, <em>RoomProperties</em> and <em>UserProperties</em>, where many specific attributes of the Room and User classes can be accessed.</p>
|
522
|
+
*
|
523
|
+
* <h4>Advanced features</h4>
|
524
|
+
* <p>The Match Expressions offer advanced capabilities of searching through nested data structures such as <em>SFSObject</em> and <em>SFSArray</em>. This is done via a very simple dot-syntax as shown in a couple of the examples below.</p>
|
525
|
+
* <p>The power of Match Expression doesn't end here. You can run multiple passes of matching if you need complex searches to be performed. For example you can run a first match and obtain a list of filtered Rooms and then use it to apply another expression to further refine your search, and so on and so forth.</p>
|
526
|
+
*
|
527
|
+
* <h4>Notes</h4>
|
528
|
+
* <ul>
|
529
|
+
* <li>For members of the <em>MatchExpression</em> class, please [refer to its Javadoc]{@link http://docs2x.smartfoxserver.com/api-docs/javadoc/server/com/smartfoxserver/v2/entities/match/MatchExpression.html}.</li>
|
530
|
+
* </ul>
|
531
|
+
*
|
532
|
+
* <h4>See also</h4>
|
533
|
+
* <ul>
|
534
|
+
* <li>{@link SFSApi#findRooms} method</li>
|
535
|
+
* <li>{@link SFSApi#findUsers} method</li>
|
536
|
+
* <li>{@link GameApi#createGame} method</li>
|
537
|
+
* <li>{@link RoomProperties}, {@link UserProperties} objects</li>
|
538
|
+
* <li>{@link BoolMatch}, {@link NumberMatch}, {@link StringMatch} enums</li>
|
539
|
+
* <li><img src="java-icon-small.png"></img> [MatchExpression]{@link http://docs2x.smartfoxserver.com/api-docs/javadoc/server/com/smartfoxserver/v2/entities/match/MatchExpression.html} class</li>
|
540
|
+
* </ul>
|
541
|
+
*
|
542
|
+
* @example
|
543
|
+
* <caption>In this example we create an expression that will look for users from Italy with a rank greater than 5.<br>
|
544
|
+
* Both "rank" and "country" are User Variables set in our game.</caption>
|
545
|
+
* var exp = new MatchExpression('rank', NumberMatch.GREATER_THAN, 5).and('country', StringMatch.EQUALS, 'Italy');
|
546
|
+
*
|
547
|
+
* @example
|
548
|
+
* <caption>In this example, using some Room properties and a Room Variable name, we retrieve a list of Rooms that a user could join to play chess.</caption>
|
549
|
+
* // Prepare a Match Expression
|
550
|
+
* var exp = new MatchExpression(RoomProperties.IS_GAME, BoolMatch.EQUALS, true)
|
551
|
+
* .and(RoomProperties.HAS_FREE_PLAYER_SLOTS, BoolMatch.EQUALS, true)
|
552
|
+
* .and("isGameStarted", BoolMatch.EQUALS, false);
|
553
|
+
* // Search Rooms
|
554
|
+
* var joinableRooms = getApi().findRooms(getParentZone().getRoomListFromGroup("chess"), exp, 0);
|
555
|
+
*
|
556
|
+
* @example
|
557
|
+
* <caption>In this example we traverse a Room Variable of type <em>SFSObject</em> via a very simple dot-syntax.<br>
|
558
|
+
* The expression goes down deep into an <em>SFSObject</em> called "europe", taking the "italy" object (another <em>SFSObject</em>) and finally reading its "capital" field and matching it with another string.</caption>
|
559
|
+
* var exp = new MatchExpression("europe.italy.capital", StringMatch.EQUALS, "Rome");
|
560
|
+
*
|
561
|
+
* @example
|
562
|
+
* <caption>The following is another example involving <em>SFSObject</em> and <em>SFSArray</em> type Variables.<br>
|
563
|
+
* From the "italy" <em>SFSObject</em> we obtain a "majorCities" <em>SFSArray</em> and we grab the third item in it (the ".3" expression means "give me the element at index == 3"). The item is again a <em>SFSObject</em> whose "name" property we finally compare to a the passed string.</caption>
|
564
|
+
* var exp = new MatchExpression("europe.italy.majorCities.3.name", StringMatch.EQUALS, "Milan");
|
565
|
+
*/
|
566
|
+
var MatchExpression = Java.type('com.smartfoxserver.v2.entities.match.MatchExpression');
|
567
|
+
|
568
|
+
/**
|
569
|
+
* Creates a new <em>MMOItem</em> instance.
|
570
|
+
*
|
571
|
+
* @param {MMOItemVariable[]} [variables=null] A list of <em>MMOItemVariable</em> objects assigned to the <em>MMOItem</em> upon creation.
|
572
|
+
*
|
573
|
+
* @class
|
574
|
+
* The <em>MMOItem</em> class represents a non-player entity inside an MMORoom.
|
575
|
+
*
|
576
|
+
* <p>MMOItems can represent bonuses, triggers, bullets or any other non-player entites inside an MMORoom; these will be handled with the same Area of Interest (AOI) rules applicable to users.
|
577
|
+
* This means that whenever one or more MMOItems fall within the AOI of a player, their presence will be notified to the client via a <em>PROXIMITY_LIST_UPDATE</em> event together with their id(s) and MMOItem Variables.</p>
|
578
|
+
*
|
579
|
+
* <h4>Notes</h4>
|
580
|
+
* <ul>
|
581
|
+
* <li>For members of the <em>MMOItem</em> class, please [refer to its Javadoc]{@link http://docs2x.smartfoxserver.com/api-docs/javadoc/server/com/smartfoxserver/v2/mmo/MMOItem.html}.</li>
|
582
|
+
* </ul>
|
583
|
+
*
|
584
|
+
* <h4>See also</h4>
|
585
|
+
* <ul>
|
586
|
+
* <li>{@link MMOApi#setMMOItemPosition} method</li>
|
587
|
+
* <li>{@link MMOItemVariable} class</li>
|
588
|
+
* <li><img src="java-icon-small.png"></img> [MMOItem]{@link http://docs2x.smartfoxserver.com/api-docs/javadoc/server/com/smartfoxserver/v2/mmo/MMOItem.html} class</li>
|
589
|
+
* </ul>
|
590
|
+
*
|
591
|
+
* @example
|
592
|
+
* <caption>In this example we create a new <em>MMOItem</em>, attaching a couple of MMOItem Variables to it.</caption>
|
593
|
+
* // Prepare the variables
|
594
|
+
* var vars = [
|
595
|
+
* new MMOItemVariable("type", "1"), // identifies the type of bonus based on our game rules
|
596
|
+
* new MMOitemVariable("val", 100) // the value of the bonus
|
597
|
+
* ];
|
598
|
+
*
|
599
|
+
* // Create the item
|
600
|
+
* var bonus = new MMOItem(vars);
|
601
|
+
*
|
602
|
+
* // Add the MMOItem to the MMORoom at specific coordinates
|
603
|
+
* getMMOApi().setMMOItemPosition(bonus, Vectors.newVec3D(10, 20, 5, false), theMMORoom);
|
604
|
+
*/
|
605
|
+
var MMOItem = Java.type('com.smartfoxserver.v2.mmo.MMOItem');
|
606
|
+
|
607
|
+
/**
|
608
|
+
* <em>EnumSet</em> is an abstract Java class. Do not instantiate it and use its static methods instead.
|
609
|
+
*
|
610
|
+
* @class
|
611
|
+
* <img src="java-icon.png"></img><br>
|
612
|
+
* The <em>EnumSet</em> class is a specialized collection to use when an API method requires a list of enum values to be passed.
|
613
|
+
*
|
614
|
+
* <p></p>
|
615
|
+
*
|
616
|
+
* <h4>Notes</h4>
|
617
|
+
* <ul>
|
618
|
+
* <li>For members of the <em>EnumSet</em> class, please [refer to its Javadoc]{@link http://docs.oracle.com/javase/8/docs/api/java/util/EnumSet.html}.</li>
|
619
|
+
* </ul>
|
620
|
+
*
|
621
|
+
* @example
|
622
|
+
* <caption>In this simple example we create a Room, setting its permissions by means of an <em>EnumSet</em>.</caption>
|
623
|
+
* var crs = new CreateRoomSettings();
|
624
|
+
* crs.setName("chat#371");
|
625
|
+
* crs.setMaxUsers(10);
|
626
|
+
*
|
627
|
+
* // Set Room permissions
|
628
|
+
* crs.setRoomSettings(EnumSet.of(SFSRoomSettings.USER_ENTER_EVENT, SFSRoomSettings.USER_EXIT_EVENT, SFSRoomSettings.PUBLIC_MESSAGES));
|
629
|
+
*
|
630
|
+
* // Create the Room
|
631
|
+
* getApi().createRoom(getParentZone(), crs, null, false, null, true, true);
|
632
|
+
*/
|
633
|
+
var EnumSet = Java.type('java.util.EnumSet');
|
634
|
+
|
635
|
+
// JSDoc not needed for this interface (never implemented by developers directly)
|
636
|
+
var InvitationCallback = Java.type('com.smartfoxserver.v2.entities.invitation.InvitationCallback');
|
637
|
+
|
638
|
+
// --- Global enums from Java scope --------------------------------------------
|
639
|
+
|
640
|
+
/**
|
641
|
+
* <img src="java-icon.png"></img><br>
|
642
|
+
* The <em>SFSRoomRemoveMode</em> enum lists all possible auto-removal modes of dynamically created Rooms.
|
643
|
+
*
|
644
|
+
* <p>Available <em>SFSRoomRemoveMode</em> values are:</p>
|
645
|
+
* <ul>
|
646
|
+
* <li><strong>DEFAULT</strong>: a regular Room is removed when it is empty and its creator is not connected anymore, while instead a game Room is removed when it is empty</li>
|
647
|
+
* <li><strong>NEVER_REMOVE</strong>: the Room is never removed (use with caution)</li>
|
648
|
+
* <li><strong>WHEN_EMPTY</strong>: the Room is removed immediately when the last user leaves it</li>
|
649
|
+
* <li><strong>WHEN_EMPTY_AND_CREATOR_IS_GONE</strong>: the Room is removed when it is empty and its creator is not connected anymore</li>
|
650
|
+
* </ul>
|
651
|
+
*
|
652
|
+
* <h5>Notes:</h5>
|
653
|
+
* <ul>
|
654
|
+
* <li>For members of the <em>SFSRoomRemoveMode</em> enum, please [refer to its Javadoc]{@link http://docs2x.smartfoxserver.com/api-docs/javadoc/server/com/smartfoxserver/v2/entities/variables/VariableType.html}.</li>
|
655
|
+
* </ul>
|
656
|
+
*
|
657
|
+
* @enum
|
658
|
+
*/
|
659
|
+
var SFSRoomRemoveMode = Java.type('com.smartfoxserver.v2.entities.SFSRoomRemoveMode');
|
660
|
+
|
661
|
+
/**
|
662
|
+
* <img src="java-icon.png"></img><br>
|
663
|
+
* The <em>SFSRoomSettings</em> enum lists all valid data types for User, Room, Buddy and MMOItem Variables.
|
664
|
+
*
|
665
|
+
* <p>Available <em>SFSRoomSettings</em> values are:</p>
|
666
|
+
* <ul>
|
667
|
+
* <li><strong>ROOM_NAME_CHANGE</strong>: toggles the ability to change the name of the Room at runtime</li>
|
668
|
+
* <li><strong>CAPACITY_CHANGE</strong>: toggles the ability to change the capacity of the Room at runtime</li>
|
669
|
+
* <li><strong>PASSWORD_STATE_CHANGE</strong>: toggles the ability to change the password of the Room at runtime</li>
|
670
|
+
* <li><strong>PUBLIC_MESSAGES</strong>: toggles the ability to send public messages in the Room</li>
|
671
|
+
* <li><strong>USER_COUNT_CHANGE_EVENT</strong>: toggles the notification of changes in the count of users and spectators in the Room</li>
|
672
|
+
* <li><strong>USER_ENTER_EVENT</strong>: toggles the notification of users entering the Room</li>
|
673
|
+
* <li><strong>USER_EXIT_EVENT</strong>: toggles the notification of users leaving the Room</li>
|
674
|
+
* <li><strong>USER_VARIABLES_UPDATE_EVENT</strong>: toggles the notification of User Variables changes the Room</li>
|
675
|
+
* </ul>
|
676
|
+
*
|
677
|
+
* <h5>Notes:</h5>
|
678
|
+
* <ul>
|
679
|
+
* <li>For members of the <em>SFSRoomSettings</em> enum, please [refer to its Javadoc]{@link http://docs2x.smartfoxserver.com/api-docs/javadoc/server/com/smartfoxserver/v2/entities/variables/VariableType.html}.</li>
|
680
|
+
* </ul>
|
681
|
+
*
|
682
|
+
* @enum
|
683
|
+
*/
|
684
|
+
var SFSRoomSettings = Java.type('com.smartfoxserver.v2.entities.SFSRoomSettings');
|
685
|
+
|
686
|
+
/**
|
687
|
+
* <img src="java-icon.png"></img><br>
|
688
|
+
* The <em>VariableType</em> enum lists all valid data types for User, Room, Buddy and MMOItem Variables.
|
689
|
+
*
|
690
|
+
* <p>Available <em>VariableType</em> values are:</p>
|
691
|
+
* <ul>
|
692
|
+
* <li><strong>NULL</strong>: a null Variable</li>
|
693
|
+
* <li><strong>BOOL</strong>: a boolean Variable</li>
|
694
|
+
* <li><strong>INT</strong>: an int Variable (32 bit integer)</li>
|
695
|
+
* <li><strong>DOUBLE</strong>: a double Variable (64 bit double precision number)</li>
|
696
|
+
* <li><strong>STRING</strong>: an utf-string Variable (UTF-8 encoded string, with length up to 32 KBytes)</li>
|
697
|
+
* <li><strong>OBJECT</strong>: a Variable of type {@link SFSObject}</li>
|
698
|
+
* <li><strong>ARRAY</strong>: a Variable of type {@link SFSArray}</li>
|
699
|
+
* </ul>
|
700
|
+
*
|
701
|
+
* <h5>Notes:</h5>
|
702
|
+
* <ul>
|
703
|
+
* <li>For members of the <em>VariableType</em> enum, please [refer to its Javadoc]{@link http://docs2x.smartfoxserver.com/api-docs/javadoc/server/com/smartfoxserver/v2/entities/variables/VariableType.html}.</li>
|
704
|
+
* </ul>
|
705
|
+
*
|
706
|
+
* @enum
|
707
|
+
*/
|
708
|
+
var VariableType = Java.type('com.smartfoxserver.v2.entities.variables.VariableType');
|
709
|
+
|
710
|
+
/**
|
711
|
+
* <img src="java-icon.png"></img><br>
|
712
|
+
* The <em>ClientDisconnectionReason</em> enum lists all possible disconnection reasons provided by the <em>USER_DISCONNECT</em> event.
|
713
|
+
*
|
714
|
+
* <p>Possible <em>ClientDisconnectionReason</em> values are:</p>
|
715
|
+
* <ul>
|
716
|
+
* <li><strong>IDLE</strong>: the client was disconnected because he was idle for longer than the time configured in the Zone as (<em>maxUserIdleTime</em> setting)</li>
|
717
|
+
* <li><strong>KICK</strong>: the client was kicked</li>
|
718
|
+
* <li><strong>BAN</strong>: the client was banned</li>
|
719
|
+
* <li><strong>UNKNOWN</strong>: the disconnection reason was not detected</li>
|
720
|
+
* </ul>
|
721
|
+
*
|
722
|
+
* <h5>Notes:</h5>
|
723
|
+
* <ul>
|
724
|
+
* <li>For members of the <em>ClientDisconnectionReason</em> enum, please [refer to its Javadoc]{@link http://docs2x.smartfoxserver.com/api-docs/javadoc/server/com/smartfoxserver/v2/util/ClientDisconnectionReason.html}.</li>
|
725
|
+
* </ul>
|
726
|
+
*
|
727
|
+
* <h5>See also:</h5>
|
728
|
+
* <ul>
|
729
|
+
* <li><img src="java-icon-small.png"></img> [SFSEventType.USER_DISCONNECT]{@link http://docs2x.smartfoxserver.com/api-docs/javadoc/server/com/smartfoxserver/v2/core/SFSEventType.html#USER_DISCONNECT} event type</li>
|
730
|
+
* </ul>
|
731
|
+
*
|
732
|
+
* @enum
|
733
|
+
*/
|
734
|
+
var ClientDisconnectionReason = Java.type('com.smartfoxserver.v2.util.ClientDisconnectionReason');
|
735
|
+
|
736
|
+
/**
|
737
|
+
* <img src="java-icon.png"></img><br>
|
738
|
+
* The <em>InvitationResponse</em> enum lists all possible replies to an invitation.
|
739
|
+
*
|
740
|
+
* <p>Possible <em>InvitationResponse</em> values are:</p>
|
741
|
+
* <ul>
|
742
|
+
* <li><strong>ACCEPT</strong>: accept the invitation</li>
|
743
|
+
* <li><strong>REFUSE</strong>: refuse the invitation</li>
|
744
|
+
* <li><strong>EXPIRED</strong>: the invitation expired before a reply was sent</li>
|
745
|
+
* </ul>
|
746
|
+
*
|
747
|
+
* <h5>Notes:</h5>
|
748
|
+
* <ul>
|
749
|
+
* <li>For members of the <em>InvitationResponse</em> enum, please [refer to its Javadoc]{@link http://docs2x.smartfoxserver.com/api-docs/javadoc/server/com/smartfoxserver/v2/entities/invitation/InvitationResponse.html}.</li>
|
750
|
+
* </ul>
|
751
|
+
*
|
752
|
+
* <h5>See also:</h5>
|
753
|
+
* <ul>
|
754
|
+
* <li>{@link GameApi#replyToInvitation} method</li>
|
755
|
+
* </ul>
|
756
|
+
*
|
757
|
+
* @enum
|
758
|
+
*/
|
759
|
+
var InvitationResponse = Java.type('com.smartfoxserver.v2.entities.invitation.InvitationResponse');
|
760
|
+
|
761
|
+
/**
|
762
|
+
* <img src="java-icon.png"></img><br>
|
763
|
+
* The <em>RoomProperties</em> object lists all Room properties that can be queried using a Match Expression.
|
764
|
+
*
|
765
|
+
* <p>Available <em>RoomProperties</em> fields are:</p>
|
766
|
+
* <ul>
|
767
|
+
* <li><strong>GROUP_ID</strong>: the id of Group to which the Room belongs</li>
|
768
|
+
* <li><strong>HAS_FREE_PLAYER_SLOTS</strong>: the Room has at least one free player slot</li>
|
769
|
+
* <li><strong>IS_GAME</strong>: the Room's <em>isGame</em> flag</li>
|
770
|
+
* <li><strong>IS_PRIVATE</strong>: the Room's <em>isPrivate</em> flag</li>
|
771
|
+
* <li><strong>IS_TYPE_SFSGAME</strong>: the Room is of type SFSGame</li>
|
772
|
+
* <li><strong>MAX_SPECTATORS</strong>: the Room's max number of spectators</li>
|
773
|
+
* <li><strong>MAX_USERS</strong>: the Room's max number of users</li>
|
774
|
+
* <li><strong>NAME</strong>: the name of the Room</li>
|
775
|
+
* <li><strong>SPECTATOR_COUNT</strong>: the number of spectators in the Room</li>
|
776
|
+
* <li><strong>USER_COUNT</strong>: the number of users in the Room</li>
|
777
|
+
* </ul>
|
778
|
+
*
|
779
|
+
* <h5>Notes:</h5>
|
780
|
+
* <ul>
|
781
|
+
* <li>For members of the <em>RoomProperties</em> object, please [refer to its Javadoc]{@link http://docs2x.smartfoxserver.com/api-docs/javadoc/server/com/smartfoxserver/v2/entities/match/RoomProperties.html}.</li>
|
782
|
+
* </ul>
|
783
|
+
*
|
784
|
+
* <h5>See also:</h5>
|
785
|
+
* <ul>
|
786
|
+
* <li>{@link MatchExpression} class</li>
|
787
|
+
* </ul>
|
788
|
+
*
|
789
|
+
* @enum
|
790
|
+
*/
|
791
|
+
var RoomProperties = Java.type('com.smartfoxserver.v2.entities.match.RoomProperties');
|
792
|
+
|
793
|
+
/**
|
794
|
+
* <img src="java-icon.png"></img><br>
|
795
|
+
* The <em>UserProperties</em> object lists all User properties that can be queried using a Match Expression.
|
796
|
+
*
|
797
|
+
* <p>Available <em>UserProperties</em> fields are:</p>
|
798
|
+
* <ul>
|
799
|
+
* <li><strong>IS_IN_ANY_ROOM</strong>: the user is currently joined in at least one Room</li>
|
800
|
+
* <li><strong>IS_NPC</strong>: the user is a Non-Player Charachter</li>
|
801
|
+
* <li><strong>IS_PLAYER</strong>: the user is a player in the joined Room</li>
|
802
|
+
* <li><strong>IS_SPECTATOR</strong>: the user is a spectator in the joined Room</li>
|
803
|
+
* <li><strong>NAME</strong>: the name of the user</li>
|
804
|
+
* <li><strong>PRIVILEGE_ID</strong>: the user's privilege id</li>
|
805
|
+
* </ul>
|
806
|
+
*
|
807
|
+
* <h5>Notes:</h5>
|
808
|
+
* <ul>
|
809
|
+
* <li>For members of the <em>UserProperties</em> object, please [refer to its Javadoc]{@link http://docs2x.smartfoxserver.com/api-docs/javadoc/server/com/smartfoxserver/v2/entities/match/UserProperties.html}.</li>
|
810
|
+
* </ul>
|
811
|
+
*
|
812
|
+
* <h5>See also:</h5>
|
813
|
+
* <ul>
|
814
|
+
* <li>{@link MatchExpression} class</li>
|
815
|
+
* </ul>
|
816
|
+
*
|
817
|
+
* @enum
|
818
|
+
*/
|
819
|
+
var UserProperties = Java.type('com.smartfoxserver.v2.entities.match.UserProperties');
|
820
|
+
|
821
|
+
/**
|
822
|
+
* <img src="java-icon.png"></img><br>
|
823
|
+
* The <em>BoolMatch</em> enum lists all boolean conditions that can be used in a Match Expression.
|
824
|
+
*
|
825
|
+
* <p>Available <em>BoolMatch</em> values are:</p>
|
826
|
+
* <ul>
|
827
|
+
* <li><strong>EQUALS</strong>: the <code>bool1 == bool2</code> condition</li>
|
828
|
+
* <li><strong>NOT_EQUALS</strong>: the <code>bool1 != bool2</code> condition</li>
|
829
|
+
* </ul>
|
830
|
+
*
|
831
|
+
* <h5>Notes:</h5>
|
832
|
+
* <ul>
|
833
|
+
* <li>For members of the <em>BoolMatch</em> enum, please [refer to its Javadoc]{@link http://docs2x.smartfoxserver.com/api-docs/javadoc/server/com/smartfoxserver/v2/entities/match/BoolMatch.html}.</li>
|
834
|
+
* </ul>
|
835
|
+
*
|
836
|
+
* <h5>See also:</h5>
|
837
|
+
* <ul>
|
838
|
+
* <li>{@link MatchExpression} class</li>
|
839
|
+
* <li>{@link NumberMatch} enum</li>
|
840
|
+
* <li>{@link StringMatch} enum</li>
|
841
|
+
* </ul>
|
842
|
+
*
|
843
|
+
* @enum
|
844
|
+
*/
|
845
|
+
var BoolMatch = Java.type('com.smartfoxserver.v2.entities.match.BoolMatch');
|
846
|
+
|
847
|
+
/**
|
848
|
+
* <img src="java-icon.png"></img><br>
|
849
|
+
* The <em>NumberMatch</em> enum lists all numeric conditions that can be used in a Match Expression.
|
850
|
+
*
|
851
|
+
* <p>Available <em>NumberMatch</em> values are:</p>
|
852
|
+
* <ul>
|
853
|
+
* <li><strong>EQUALS</strong>: the <code>num1 == num2</code> condition</li>
|
854
|
+
* <li><strong>GREATER_THAN</strong>: the <code>num1 > num2</code> condition</li>
|
855
|
+
* <li><strong>GREATER_THAN_OR_EQUAL_TO</strong>: the <code>num1 >= num2</code> condition</li>
|
856
|
+
* <li><strong>LESS_THAN</strong>: the <code>num1 < num2</code> condition</li>
|
857
|
+
* <li><strong>LESS_THAN_OR_EQUAL_TO</strong>: the <code>num1 <= num2</code> condition</li>
|
858
|
+
* <li><strong>NOT_EQUALS</strong>: the <code>num1 != num2</code> condition</li>
|
859
|
+
* </ul>
|
860
|
+
*
|
861
|
+
* <h5>Notes:</h5>
|
862
|
+
* <ul>
|
863
|
+
* <li>For members of the <em>NumberMatch</em> enum, please [refer to its Javadoc]{@link http://docs2x.smartfoxserver.com/api-docs/javadoc/server/com/smartfoxserver/v2/entities/match/NumberMatch.html}.</li>
|
864
|
+
* </ul>
|
865
|
+
*
|
866
|
+
* <h5>See also:</h5>
|
867
|
+
* <ul>
|
868
|
+
* <li>{@link MatchExpression} class</li>
|
869
|
+
* <li>{@link BoolMatch} enum</li>
|
870
|
+
* <li>{@link StringMatch} enum</li>
|
871
|
+
* </ul>
|
872
|
+
*
|
873
|
+
* @enum
|
874
|
+
*/
|
875
|
+
var NumberMatch = Java.type('com.smartfoxserver.v2.entities.match.NumberMatch');
|
876
|
+
|
877
|
+
/**
|
878
|
+
* <img src="java-icon.png"></img><br>
|
879
|
+
* The <em>StringMatch</em> enum lists all string-related conditions that can be used in a Match Expression.
|
880
|
+
*
|
881
|
+
* <p>Available <em>StringMatch</em> values are:</p>
|
882
|
+
* <ul>
|
883
|
+
* <li><strong>CONTAINS</strong>: the <code>str1.indexOf(str2) > -1</code> condition</li>
|
884
|
+
* <li><strong>ENDS_WITH</strong>: the <code>str1.endsWith(str2)</code> condition</li>
|
885
|
+
* <li><strong>EQUALS</strong>: the <code>str1.equals(str2)</code> condition</li>
|
886
|
+
* <li><strong>NOT_EQUALS</strong>: the <code>!str1.equals(str2)</code> condition</li>
|
887
|
+
* <li><strong>STARTS_WITH</strong>: the <code>str1.startsWith(str2)</code> condition</li>
|
888
|
+
* </ul>
|
889
|
+
*
|
890
|
+
* <h5>Notes:</h5>
|
891
|
+
* <ul>
|
892
|
+
* <li>For members of the <em>StringMatch</em> enum, please [refer to its Javadoc]{@link http://docs2x.smartfoxserver.com/api-docs/javadoc/server/com/smartfoxserver/v2/entities/match/StringMatch.html}.</li>
|
893
|
+
* </ul>
|
894
|
+
*
|
895
|
+
* <h5>See also:</h5>
|
896
|
+
* <ul>
|
897
|
+
* <li>{@link MatchExpression} class</li>
|
898
|
+
* <li>{@link BoolMatch} enum</li>
|
899
|
+
* <li>{@link NumberMatch} enum</li>
|
900
|
+
* </ul>
|
901
|
+
*
|
902
|
+
* @enum
|
903
|
+
*/
|
904
|
+
var StringMatch = Java.type('com.smartfoxserver.v2.entities.match.StringMatch');
|
905
|
+
|
906
|
+
/**
|
907
|
+
* <img src="java-icon.png"></img><br>
|
908
|
+
* The <em>SFSEventType</em> object lists all server-side events dispatched to an Extension, provided an handler was registered.
|
909
|
+
*
|
910
|
+
* <p>Available <em>SFSEventType</em> fields are:</p>
|
911
|
+
* <ul>
|
912
|
+
* <li><strong>BUDDY_ADD</strong>: the event fired when a user is added in the Buddy List of another client</li>
|
913
|
+
* <li><strong>BUDDY_BLOCK</strong>: the event fired when a Buddy is blocked in user's Buddy List</li>
|
914
|
+
* <li><strong>BUDDY_LIST_INIT</strong>: the event fired when a user initializes his Buddy List</li>
|
915
|
+
* <li><strong>BUDDY_MESSAGE</strong>: the event fired when a Buddy Message is exchanged between two buddies</li>
|
916
|
+
* <li><strong>BUDDY_ONLINE_STATE_UPDATE</strong>: the event fired when a buddy changes his online state</li>
|
917
|
+
* <li><strong>BUDDY_REMOVE</strong>: the event fired when a user is removed in the Buddy List of another client</li>
|
918
|
+
* <li><strong>BUDDY_VARIABLES_UPDATE</strong>: the event fired when one or more Buddy Variables are set by a user</li>
|
919
|
+
* <li><strong>FILE_UPLOAD</strong>: the event fired when one or more files have been uploaded by a user connected in the current Zone</li>
|
920
|
+
* <li><strong>GAME_INVITATION_FAILURE</strong>: the event fired after a private SFSGame has finished the cycle of invitations with an error</li>
|
921
|
+
* <li><strong>GAME_INVITATION_SUCCESS</strong>: the event fired after a private SFSGame has finished the cycle of invitations successfully</li>
|
922
|
+
* <li><strong>PLAYER_TO_SPECTATOR</strong>: the event fired when a user joined in a Game Room as a player is turned into a spectator</li>
|
923
|
+
* <li><strong>PRIVATE_MESSAGE</strong>: the event fired when a private message is sent by a client</li>
|
924
|
+
* <li><strong>PUBLIC_MESSAGE</strong>: the event fired when a public message is sent by a client</li>
|
925
|
+
* <li><strong>ROOM_ADDED</strong>: the event fired after a new Room was created in the current Zone</li>
|
926
|
+
* <li><strong>ROOM_REMOVED</strong>: the event fired after a Room was removed from the current Zone</li>
|
927
|
+
* <li><strong>ROOM_VARIABLES_UPDATE</strong>: the event fired when one or more Room Variables are set</li>
|
928
|
+
* <li><strong>SERVER_READY</strong>: the event fired when SmartFoxServer has completed the boot phase</li>
|
929
|
+
* <li><strong>SPECTATOR_TO_PLAYER</strong>: the event fired when a user joined in a Game Room as a spectator is turned into a player</li>
|
930
|
+
* <li><strong>USER_DISCONNECT</strong>: the event fired after a user disconnects himself or is disconnected</li>
|
931
|
+
* <li><strong>USER_JOIN_ROOM</strong>: the event fired after a user has joined a Room</li>
|
932
|
+
* <li><strong>USER_JOIN_ZONE</strong>: the event fired after a successful user login</li>
|
933
|
+
* <li><strong>USER_LEAVE_ROOM</strong>: the event fired after a user has left a Room</li>
|
934
|
+
* <li><strong>USER_LOGIN</strong>: the event fired when a user sends a login request</li>
|
935
|
+
* <li><strong>USER_LOGOUT</strong>: the event fired after a user logged out of the current Zone</li>
|
936
|
+
* <li><strong>USER_RECONNECTION_SUCCESS</strong>: the event fired when the HRC system is active and a client was successfully reconnected (feature not available for JavaScript clients)</li>
|
937
|
+
* <li><strong>USER_RECONNECTION_TRY</strong>: the event fired when the HRC system is active and a client is trying to reconnect (feature not available for JavaScript clients)</li>
|
938
|
+
* <li><strong>USER_VARIABLES_UPDATE</strong>: the event fired when one or more User Variables are set</li>
|
939
|
+
* </ul>
|
940
|
+
*
|
941
|
+
* <h5>Notes:</h5>
|
942
|
+
* <ul>
|
943
|
+
* <li>For members of the <em>SFSEventType</em> object, please [refer to its Javadoc]{@link http://docs2x.smartfoxserver.com/api-docs/javadoc/server/com/smartfoxserver/v2/core/SFSEventType.html}.</li>
|
944
|
+
* </ul>
|
945
|
+
*
|
946
|
+
* <h5>See also:</h5>
|
947
|
+
* <ul>
|
948
|
+
* <li>{@link addEventHandler} method</li>
|
949
|
+
* </ul>
|
950
|
+
*
|
951
|
+
* @enum
|
952
|
+
*/
|
953
|
+
var SFSEventType = Java.type('com.smartfoxserver.v2.core.SFSEventType');
|
954
|
+
|
955
|
+
// --- Global functions --------------------------------------------------------
|
956
|
+
|
957
|
+
var asJavaList = $$Util.toList;
|
958
|
+
var asArray = $$Util.toArray;
|
959
|
+
|
960
|
+
// --- Sub API instances -------------------------------------------------------
|
961
|
+
|
962
|
+
var $$Api_Instance = new SFSApi();
|
963
|
+
var $$GameApi_Instance = new GameApi();
|
964
|
+
var $$BuddyApi_Instance = new BuddyApi();
|
965
|
+
var $$MMOApi_Instance = new MMOApi();
|
966
|
+
var $$FileApi_Instance = new FileApi();
|
967
|
+
|
968
|
+
// --- Public methods ----------------------------------------------------------
|
969
|
+
|
970
|
+
/**
|
971
|
+
* Includes other JavaScript files in the Extension.<br>
|
972
|
+
* This helps writing modular code, where classes, functions and other objects are divided into separate folders and/or files.
|
973
|
+
*
|
974
|
+
* @param {string} scriptPath The path of the JavaScript file to be included, relative to the main Extension script's folder.
|
975
|
+
*/
|
976
|
+
function include(scriptPath)
|
977
|
+
{
|
978
|
+
var path = com.smartfoxserver.v2.config.DefaultConstants.EXTENSION_FOLDER + $$WrapperExt.getName() + "/" + scriptPath;
|
979
|
+
load(path);
|
980
|
+
}
|
981
|
+
|
982
|
+
/**
|
983
|
+
* Outputs the passed arguments to the console and log file.<br>
|
984
|
+
* This is useful for remote debugging when developing Extensions.
|
985
|
+
*
|
986
|
+
* @param {...*} arguments Any number of strings or objects to trace.
|
987
|
+
*/
|
988
|
+
function trace()
|
989
|
+
{
|
990
|
+
var args = Array.prototype.slice.call(arguments);
|
991
|
+
var message = args.join(" ");
|
992
|
+
|
993
|
+
$$WrapperExt.trace(message);
|
994
|
+
}
|
995
|
+
|
996
|
+
/**
|
997
|
+
* Returns a reference to the <em>SFSApi</em> class instance, providing access to the main SmartFoxServer 2X server side API.
|
998
|
+
*
|
999
|
+
* <h5>See also:</h5>
|
1000
|
+
* <ul>
|
1001
|
+
* <li>{@link getBuddyApi} method</li>
|
1002
|
+
* <li>{@link getGameApi} method</li>
|
1003
|
+
* <li>{@link getMMOApi} method</li>
|
1004
|
+
* <li>{@link getFileApi} method</li>
|
1005
|
+
* </ul>
|
1006
|
+
*
|
1007
|
+
* @return {SFSApi} A reference to the <em>SFSApi</em> class instance.
|
1008
|
+
*/
|
1009
|
+
function getApi()
|
1010
|
+
{
|
1011
|
+
return $$Api_Instance;
|
1012
|
+
}
|
1013
|
+
|
1014
|
+
/**
|
1015
|
+
* Returns a reference to the <em>BuddyApi</em> class instance, providing access to the specialized server side API related to Buddy List features.
|
1016
|
+
*
|
1017
|
+
* @return {BuddyApi} A reference to the <em>BuddyApi</em> class instance.
|
1018
|
+
*/
|
1019
|
+
function getBuddyApi()
|
1020
|
+
{
|
1021
|
+
return $$BuddyApi_Instance;
|
1022
|
+
}
|
1023
|
+
|
1024
|
+
/**
|
1025
|
+
* Returns a reference to the <em>GameApi</em> class instance, providing access to the specialized server side API related to SFSGame features.
|
1026
|
+
*
|
1027
|
+
* @return {GameApi} A reference to the <em>GameApi</em> class instance.
|
1028
|
+
*/
|
1029
|
+
function getGameApi()
|
1030
|
+
{
|
1031
|
+
return $$GameApi_Instance;
|
1032
|
+
}
|
1033
|
+
|
1034
|
+
/**
|
1035
|
+
* Returns a reference to the <em>MMOApi</em> class instance, providing access to the specialized server side API related to MMO features.
|
1036
|
+
*
|
1037
|
+
* @return {MMOApi} A reference to the <em>MMOApi</em> class instance.
|
1038
|
+
*/
|
1039
|
+
function getMMOApi()
|
1040
|
+
{
|
1041
|
+
return $$MMOApi_Instance;
|
1042
|
+
}
|
1043
|
+
|
1044
|
+
/**
|
1045
|
+
* Returns a reference to the <em>FileApi</em> class instance, providing access to the specialized server side API related to files management.
|
1046
|
+
*
|
1047
|
+
* @return {FileApi} A reference to the <em>FileApi</em> class instance.
|
1048
|
+
*/
|
1049
|
+
function getFileApi()
|
1050
|
+
{
|
1051
|
+
return $$FileApi_Instance;
|
1052
|
+
}
|
1053
|
+
|
1054
|
+
/**
|
1055
|
+
* Returns a reference to the <img src="java-icon-small.png"></img> [SFSDBManager]{@link http://docs2x.smartfoxserver.com/api-docs/javadoc/server/com/smartfoxserver/v2/db/SFSDBManager.html} class instance attached to the Zone to which the Extension belongs.
|
1056
|
+
*
|
1057
|
+
* <p>The Database Manager takes care of the connection to a database using either JDBC native drivers or JDBC-ODBC bridge; it provides configurable connection pooling for optimal performance and resource usage.<br>
|
1058
|
+
* Each Zone runs its own Database Manager, which can be configured via the Zone Configurator module in the SmartFoxServer 2X Administration Tool.</p>
|
1059
|
+
*
|
1060
|
+
* @return {SFSDBManager} A reference to the <img src="java-icon-small.png"></img> [SFSDBManager]{@link http://docs2x.smartfoxserver.com/api-docs/javadoc/server/com/smartfoxserver/v2/db/SFSDBManager.html} class instance.
|
1061
|
+
*/
|
1062
|
+
function getDBManager()
|
1063
|
+
{
|
1064
|
+
return $$WrapperExt.getParentZone().getDBManager();
|
1065
|
+
}
|
1066
|
+
|
1067
|
+
/**
|
1068
|
+
* Sends an Extension message/response to a list of recipients.
|
1069
|
+
*
|
1070
|
+
* <p>The Extension response can be sent using the UDP protocol instead of the default TCP protocol. This is an unrealiable network protocol that does not guarantee delivery and ordering of the packets, but it can be useful for fast data transfer speed in real-time type games (typically for position/transformation updates).<br>
|
1071
|
+
* UDP messages can be sent to clients if: 1) the client technology supports it (for example HTML5 clients DO NOT support UDP); 2) the client has already initialized the UDP protocol transmission.</p>
|
1072
|
+
*
|
1073
|
+
* @param {string} cmdName The name of the command, which identifies an action that should be executed by the client, or a response that the client is waiting for.
|
1074
|
+
* @param {SFSObject} params An <em>SFSObject</em> containing custom data to be sent to the client. If <code>null</code> is passed, no other data than the command name is sent.
|
1075
|
+
* @param {SFSUser[]} recipients An array of <img src="java-icon-small.png"></img> [SFSUser]{@link http://docs2x.smartfoxserver.com/api-docs/javadoc/server/com/smartfoxserver/v2/entities/SFSUser.html} objects identifying the recipients of the message.
|
1076
|
+
* @param {boolean} [isUdp=false] If <code>true</code>, the message will be sent using the UDP protocol.
|
1077
|
+
*
|
1078
|
+
* @example
|
1079
|
+
* <caption>In this example we register a request handler for command "sum" during the Extension initialization.
|
1080
|
+
* The Extension can then receive the "sum" request containing two integers from any client, calculate their sum and send it back to the requester.</caption>
|
1081
|
+
* function init()
|
1082
|
+
* {
|
1083
|
+
* // Register client request handlers
|
1084
|
+
* addRequestHandler("sum", onSumRequest);
|
1085
|
+
* }
|
1086
|
+
*
|
1087
|
+
* function onSumRequest(inParams, sender)
|
1088
|
+
* {
|
1089
|
+
* var n1 = inParams.getInt("n1");
|
1090
|
+
* var n2 = inParams.getInt("n2");
|
1091
|
+
*
|
1092
|
+
* var outParams = new SFSObject();
|
1093
|
+
* outParams.putInt("s", n1+n2);
|
1094
|
+
*
|
1095
|
+
* // Send response
|
1096
|
+
* send("sum", outParams, [sender]);
|
1097
|
+
* }
|
1098
|
+
*/
|
1099
|
+
function send(cmdName, params, recipients, isUdp)
|
1100
|
+
{
|
1101
|
+
$$WrapperExt.send(cmdName, params, recipients, isUdp);
|
1102
|
+
}
|
1103
|
+
|
1104
|
+
/**
|
1105
|
+
* Registers a request handler for a specific command.
|
1106
|
+
*
|
1107
|
+
* <p>Request handlers can be registered in the Extension's <em>init</em> method.</p>
|
1108
|
+
*
|
1109
|
+
* @param {string} cmdName The name of the command, which identifies the request sent by the client.
|
1110
|
+
* @param {reqHandlerFn} reqHandlerFn The function that will handle the incoming request.
|
1111
|
+
*
|
1112
|
+
* @example
|
1113
|
+
* <caption>In this example we register a request handler for command "sum" during the Extension initialization.
|
1114
|
+
* The Extension can then receive the "sum" request containing two integers from any client, calculate their sum and send it back to the requester.</caption>
|
1115
|
+
* function init()
|
1116
|
+
* {
|
1117
|
+
* // Register client request handlers
|
1118
|
+
* addRequestHandler("sum", onSumRequest);
|
1119
|
+
* }
|
1120
|
+
*
|
1121
|
+
* function onSumRequest(inParams, sender)
|
1122
|
+
* {
|
1123
|
+
* var n1 = inParams.getInt("n1");
|
1124
|
+
* var n2 = inParams.getInt("n2");
|
1125
|
+
*
|
1126
|
+
* var outParams = new SFSObject();
|
1127
|
+
* outParams.putInt("s", n1+n2);
|
1128
|
+
*
|
1129
|
+
* // Send response
|
1130
|
+
* send("sum", outParams, [sender]);
|
1131
|
+
* }
|
1132
|
+
*/
|
1133
|
+
function addRequestHandler(cmdName, reqHandlerFn)
|
1134
|
+
{
|
1135
|
+
$$RequestHandlers.put(cmdName, reqHandlerFn);
|
1136
|
+
}
|
1137
|
+
|
1138
|
+
/**
|
1139
|
+
* This callback function is called when the Extension receives a request from a client for which an handler has been registered using the {@link addRequestHandler} method.
|
1140
|
+
*
|
1141
|
+
* @callback reqHandlerFn
|
1142
|
+
*
|
1143
|
+
* @param {SFSObject} params The <em>SFSObject</em> containing the parameters attached to the client request.
|
1144
|
+
* @param {SFSUser} sender The <img src="java-icon-small.png"></img> [SFSUser]{@link http://docs2x.smartfoxserver.com/api-docs/javadoc/server/com/smartfoxserver/v2/entities/SFSUser.html} object identifying the sender of the request.
|
1145
|
+
*/
|
1146
|
+
|
1147
|
+
/**
|
1148
|
+
* Registers an handler for an inner server event.
|
1149
|
+
*
|
1150
|
+
* <p>All available event types fired by the server are listed in the <em>SFSEventType</em> enum.<br>
|
1151
|
+
* Event handlers can be registered in the Extension's <em>init</em> method; they receive an <img src="java-icon-small.png"></img> [SFSEvent]{@link http://docs2x.smartfoxserver.com/api-docs/javadoc/server/com/smartfoxserver/v2/core/SFSEvent.html} object as the only parameter.</p>
|
1152
|
+
*
|
1153
|
+
* <h5>See also:</h5>
|
1154
|
+
* <ul>
|
1155
|
+
* <li>{@link SFSEventType} enum</li>
|
1156
|
+
* <li><img src="java-icon-small.png"></img> [SFSEvent]{@link http://docs2x.smartfoxserver.com/api-docs/javadoc/server/com/smartfoxserver/v2/core/SFSEvent.html} class</li>
|
1157
|
+
* </ul>
|
1158
|
+
*
|
1159
|
+
* @param {SFSEventType} eventType One of the event types listed in the <em>SFSEventType</em> enum.
|
1160
|
+
* @param {evtHandlerFn} evtHandlerFn The function that will handle the event.
|
1161
|
+
*
|
1162
|
+
* @example
|
1163
|
+
* <caption>In this example we register an handler for the <em>SERVER_READY</em> event type during the Extension initialization.</caption>
|
1164
|
+
* function init()
|
1165
|
+
* {
|
1166
|
+
* // Register event handlers
|
1167
|
+
* addEventHandler(SFSEventType.SERVER_READY, onExtensionReady);
|
1168
|
+
* }
|
1169
|
+
*
|
1170
|
+
* function onExtensionReady(event)
|
1171
|
+
* {
|
1172
|
+
* trace("Extension is ready");
|
1173
|
+
* }
|
1174
|
+
*/
|
1175
|
+
function addEventHandler(eventType, evtHandlerFn)
|
1176
|
+
{
|
1177
|
+
$$EventHandlers.put(eventType, evtHandlerFn);
|
1178
|
+
$$WrapperExt.addEventListener(eventType, $$WrapperExt);
|
1179
|
+
}
|
1180
|
+
|
1181
|
+
/**
|
1182
|
+
* This callback function is called when the Extension receives an event fired by the server for which an handler has been registered using the {@link addEventHandler} method.
|
1183
|
+
*
|
1184
|
+
* @callback evtHandlerFn
|
1185
|
+
*
|
1186
|
+
* @param {SFSEvent} event The <img src="java-icon-small.png"></img> [SFSEvent]{@link http://docs2x.smartfoxserver.com/api-docs/javadoc/server/com/smartfoxserver/v2/core/SFSEvent.html} object containing the parameters of the specific event.
|
1187
|
+
*/
|
1188
|
+
|
1189
|
+
/**
|
1190
|
+
* Returns the <img src="java-icon-small.png"></img> [SFSRoom]{@link http://docs2x.smartfoxserver.com/api-docs/javadoc/server/com/smartfoxserver/v2/entities/SFSRoom.html} object to which this Extension is attached (for Room-level Extensions only).
|
1191
|
+
*
|
1192
|
+
* @return {SFSRoom} The <img src="java-icon-small.png"></img> [SFSRoom]{@link http://docs2x.smartfoxserver.com/api-docs/javadoc/server/com/smartfoxserver/v2/entities/SFSRoom.html} object to which the Extension is attached, or <code>null</code> if this is not a Room-level Extension.
|
1193
|
+
*/
|
1194
|
+
function getParentRoom()
|
1195
|
+
{
|
1196
|
+
return $$WrapperExt.getParentRoom();
|
1197
|
+
}
|
1198
|
+
|
1199
|
+
/**
|
1200
|
+
* Returns the <img src="java-icon-small.png"></img> [SFSZone]{@link http://docs2x.smartfoxserver.com/api-docs/javadoc/server/com/smartfoxserver/v2/entities/SFSZone.html} object which is parent to this Extension.
|
1201
|
+
*
|
1202
|
+
* <p>If case of a Zone-level Extension, this method returns its parent Extension; in case of a Room-level Extension, it returns the Zone to which the Room belongs.</p>
|
1203
|
+
*
|
1204
|
+
* @return {SFSZone} The <img src="java-icon-small.png"></img> [SFSZone]{@link http://docs2x.smartfoxserver.com/api-docs/javadoc/server/com/smartfoxserver/v2/entities/SFSZone.html} object to which the Extension belongs.
|
1205
|
+
*/
|
1206
|
+
function getParentZone()
|
1207
|
+
{
|
1208
|
+
return $$WrapperExt.getParentZone();
|
1209
|
+
}
|
1210
|
+
|
1211
|
+
/**
|
1212
|
+
* Returns the relative path to the current Extension folder.
|
1213
|
+
*
|
1214
|
+
* <p>Typically this method will return a string like "extensions/{name-of-extension}/".
|
1215
|
+
* The path is relative to the server root folder and it can be used to load external data files that are stored together with the Extension's JavaScript file(s).</p>
|
1216
|
+
*
|
1217
|
+
* @return {string} The path of the current Extension folder.
|
1218
|
+
*/
|
1219
|
+
function getCurrentFolder()
|
1220
|
+
{
|
1221
|
+
return $$WrapperExt.getCurrentFolder();
|
1222
|
+
}
|
1223
|
+
|
1224
|
+
/**
|
1225
|
+
* Changes the thread safety setting of the current Extension. By default thread-safety is enabled.
|
1226
|
+
*
|
1227
|
+
* <h5>Important note:</h5>
|
1228
|
+
* <ul>
|
1229
|
+
* <li>Disabling the Extension's thread safety can be risky. JavaScript is not a thread-safe language, so disabling the thread safety will introduce concurrency issues that can be solved by using the appropriate Java classes/collections only.<br>
|
1230
|
+
* Learn more about concurrency in JavaScript Extensions [in this article]{@link http://docs2x.smartfoxserver.com/ServerSideJS/advanced-concepts}.</li>
|
1231
|
+
* </ul>
|
1232
|
+
*
|
1233
|
+
* @param {boolean} value If <code>false</code>, the Extension will run as non thread-safe.
|
1234
|
+
*/
|
1235
|
+
function setThreadSafe(value)
|
1236
|
+
{
|
1237
|
+
$$WrapperExt.setThreadSafe(value);
|
1238
|
+
}
|
1239
|
+
|
1240
|
+
// --- Private methods ---------------------------------------------------------
|
1241
|
+
|
1242
|
+
function $$handleClientRequest(cmd, params, sender)
|
1243
|
+
{
|
1244
|
+
var handlerFn = $$RequestHandlers.get(cmd);
|
1245
|
+
|
1246
|
+
if (handlerFn === null)
|
1247
|
+
{
|
1248
|
+
$$WrapperExt.getLogger().error
|
1249
|
+
(
|
1250
|
+
"No handlers for Extension command: " + cmd +
|
1251
|
+
", Zone: " + getParentZone() +
|
1252
|
+
", EXT: " + $$WrapperExt.getName() +
|
1253
|
+
", Level: " + $$WrapperExt.getLevel()
|
1254
|
+
);
|
1255
|
+
|
1256
|
+
return;
|
1257
|
+
}
|
1258
|
+
|
1259
|
+
// Invoke request handler
|
1260
|
+
handlerFn(params, sender);
|
1261
|
+
}
|
1262
|
+
|
1263
|
+
function $$handleServerEvent(sfsEvent)
|
1264
|
+
{
|
1265
|
+
var evtType = sfsEvent.getType();
|
1266
|
+
var evtHandler = $$EventHandlers.get(evtType);
|
1267
|
+
|
1268
|
+
if (evtHandler === null)
|
1269
|
+
{
|
1270
|
+
$$WrapperExt.getLogger().error("Unknown SFSEvent handler for type: " + evtType);
|
1271
|
+
return;
|
1272
|
+
}
|
1273
|
+
|
1274
|
+
// Invoke event handler
|
1275
|
+
evtHandler(sfsEvent);
|
1276
|
+
}
|
1277
|
+
|
1278
|
+
function $$handleInternalMessage(cmd, params)
|
1279
|
+
{
|
1280
|
+
var targetFn = this.handleInternalMessage;
|
1281
|
+
var res = null;
|
1282
|
+
|
1283
|
+
if (targetFn)
|
1284
|
+
res = targetFn(cmd, params);
|
1285
|
+
|
1286
|
+
return res;
|
1287
|
+
}
|
1288
|
+
|
1289
|
+
function $$destroy()
|
1290
|
+
{
|
1291
|
+
// Clear internal data
|
1292
|
+
$$RequestHandlers.clear();
|
1293
|
+
$$EventHandlers.clear();
|
1294
|
+
|
1295
|
+
// Call Extension's own destroy, if available
|
1296
|
+
if (this.destroy)
|
1297
|
+
destroy();
|
1298
|
+
}
|