"Smartfoxserver2x Setup in Eclipse"
Writing SmartFoxServer2x Extension Program in Eclipse (step by step)
Follows These steps To Create/Configure New Zone
Step 1:- Open Eclipse and create a New Java Project
Step 2:- Name The Java Project I assumed it as "MySFSPorject"
Step 3:- Create a library folder named "lib" to place SmartfoxServer2x library files to create SmartfoxExtension.
Step 4:- In order to create a SmartFoxServer2X Extension program we need the following jar files, those are available in SFS2x-<lib folder select those
- sfs2x.jar
- sfs2x-core.jar
- log4j-x.jar
- slf4j-api.x.jar
- slf4j-log.x.jar
Copy the above jars and paste it into lib folder created in the earlier step.
Step 5:- Add the above pasted jars
to java build path as
Select project -< rightclick and
select “properties”-<select ‘javabuildpath’ - < Select
‘Libraries’ Tab -< Click ‘Add Jars’ -< select the above 5
jars pasted in your ‘lib’ folder -< press ok button.
Step 6:- Create a new ‘Class’ named
MySFSExtension under package 'com.tutorialtous.smartfox' as a
child class of SFSExtension.
New-< java class
Step 7:- Now Write the following code in MySFSExtension.java file
package com.tutorialtous.smartfox; import com.smartfoxserver.v2.extensions.SFSExtension; public class MySFSExtension extends SFSExtension { public void init() { trace("MySFSExtension Init method fired"); initEventHandlers(); initClientRequestHandlers(); } private void initClientRequestHandlers() { } private void initEventHandlers() { } @Override public void destroy() { trace("MySFSExtension destroy fired while Smartfox is going down"); } }
Step 8:- Create a Folder under extensions folder (SFS2X-<extensions), I am creating a folder name MyExtension (SFS2X-<extensions->MyExtension).
Step 9:- Now Create a Jar file using Exports option of eclipse by selecting the current project src. Means
- Select src folder project
- Right click , choose EXPORT option and select JAR option.
- Now Browse button and select the extension folder created in last step
- Name the jar and press ok
Step 10:-
Configure/Create the zone (I created a zone named
‘CasinoGameServer’ under zones folder)
Main Part to
configure is
<extension> <name>MyExtension</name> <type>JAVA</type> <file>com.tutorialtous.smartfox.MySFSExtension</file> <propertiesFile></propertiesFile> <reloadMode>AUTO</reloadMode> </extension>
Step 11:- :- Restart the
SmartfoxServer using batch file sfs2x.bat located in SFS2x
folder SFS2x-<sfs2x.bat.
Now you will see a zone name
echo with the trace of init() method in the console as