Monday, July 15, 2013

Zones Configuration files

      In Smartfox server, we can create zones. Zones are generally the name of the game app. We have numerous zones each specific to a game. In each zone, we can create rooms. These rooms can be chat, game, news, public etc.

     Whenever a user is logged into server, he is generally assigned to a room. This can be a public room. This room is specially used for public chat. Server can use this room to push any public message to the user.

     Zones can be created via logging into the admin url (http://10.0.3.74:8080/admin). Here we have left panel with different image button. Click on the zone configurator.


You can create a zone and can add as many rooms as you want. When you add a zone, smart fox creates an xml files in zones directory of your smartfox installation. The file name is the name of your zone given in the admin tool.

in my case it will created MyGame.zone. This file has all the details related to the zones and rooms.

<zone>
  <name>MyGame</name>
  <isCustomLogin>false</isCustomLogin>
  <isForceLogout>true</isForceLogout>
  <applyWordsFilterToUserName>true</applyWordsFilterToUserName>
  <applyWordsFilterToRoomName>true</applyWordsFilterToRoomName>
  <applyWordsFilterToPrivateMessages>true</applyWordsFilterToPrivateMessages>
  <isFilterBuddyMessages>true</isFilterBuddyMessages>
  <maxUsers>1000</maxUsers>
  <maxUserVariablesAllowed>5</maxUserVariablesAllowed>
  <maxRoomVariablesAllowed>5</maxRoomVariablesAllowed>
  <minRoomNameChars>3</minRoomNameChars>
  <maxRoomNameChars>10</maxRoomNameChars>
  <maxRooms>500</maxRooms>
  <maxRoomsCreatedPerUser>3</maxRoomsCreatedPerUser>
  <userCountChangeUpdateInterval>1000</userCountChangeUpdateInterval>
  <userReconnectionSeconds>0</userReconnectionSeconds>
  <overrideMaxUserIdleTime>120</overrideMaxUserIdleTime>
  <allowGuestUsers>true</allowGuestUsers>
  <guestUserNamePrefix>Guest#</guestUserNamePrefix>
  <publicRoomGroups>default,games,chat</publicRoomGroups>
  <defaultRoomGroups>default,games,chat</defaultRoomGroups>
  <defaultPlayerIdGeneratorClass></defaultPlayerIdGeneratorClass>
  <wordsFilter active="false">
    <useWarnings>false</useWarnings>
    <warningsBeforeKick>3</warningsBeforeKick>
    <kicksBeforeBan>2</kicksBeforeBan>
    <banDuration>1440</banDuration>
    <maxBadWordsPerMessage>0</maxBadWordsPerMessage>
    <kicksBeforeBanMinutes>3</kicksBeforeBanMinutes>
    <secondsBeforeBanOrKick>5</secondsBeforeBanOrKick>
    <warningMessage>Stop swearing or you will be banned</warningMessage>
    <kickMessage>Swearing not allowed: you are being kicked</kickMessage>
    <banMessage>Too much swearing: you are banned</banMessage>
    <wordsFile>config/wordsFile.txt</wordsFile>
    <filterMode>WHITELIST</filterMode>
    <banMode>NAME</banMode>
    <hideBadWordWithCharacter>*</hideBadWordWithCharacter>
  </wordsFilter>
  <floodFilter active="false">
    <banDurationMinutes>1440</banDurationMinutes>
    <maxFloodingAttempts>5</maxFloodingAttempts>
    <secondsBeforeBan>5</secondsBeforeBan>
    <banMode>NAME</banMode>
    <logFloodingAttempts>true</logFloodingAttempts>
    <banMessage>Too much flooding, you are banned</banMessage>
  </floodFilter>
  <rooms>
    <room>
      <name>game</name>
      <groupId>games</groupId>
      <password></password>
      <maxUsers>2</maxUsers>
      <maxSpectators>0</maxSpectators>
      <isDynamic>true</isDynamic>
      <isGame>true</isGame>
      <isHidden>false</isHidden>
      <autoRemoveMode>DEFAULT</autoRemoveMode>
      <permissions>
        <flags>PASSWORD_STATE_CHANGE,PUBLIC_MESSAGES</flags>
        <maxRoomVariablesAllowed>10</maxRoomVariablesAllowed>
      </permissions>
      <events>USER_ENTER_EVENT,USER_EXIT_EVENT,USER_COUNT_CHANGE_EVENT,USER_VARIABLES_UPDATE_EVENT</events>
      <badWordsFilter isActive="false"/>
      <roomVariables/>
      <extension>
        <name></name>
        <type>JAVA</type>
        <file></file>
        <propertiesFile></propertiesFile>
        <reloadMode>AUTO</reloadMode>
      </extension>
    </room>
    <room>
      <name>chat</name>
      <groupId>chats</groupId>
      <password></password>
      <maxUsers>2147483647</maxUsers>
      <maxSpectators>0</maxSpectators>
      <isDynamic>false</isDynamic>
      <isGame>false</isGame>
      <isHidden>false</isHidden>
      <autoRemoveMode>DEFAULT</autoRemoveMode>
      <permissions>
        <flags>PASSWORD_STATE_CHANGE,PUBLIC_MESSAGES</flags>
        <maxRoomVariablesAllowed>10</maxRoomVariablesAllowed>
      </permissions>
      <events>USER_ENTER_EVENT,USER_EXIT_EVENT,USER_COUNT_CHANGE_EVENT,USER_VARIABLES_UPDATE_EVENT</events>
      <badWordsFilter isActive="false"/>
      <roomVariables/>
      <extension>
        <name></name>
        <type>JAVA</type>
        <file></file>
        <propertiesFile></propertiesFile>
        <reloadMode>AUTO</reloadMode>
      </extension>
    </room>
  </rooms>
  <disabledSystemEvents/>
  <privilegeManager active="false">
    <profiles class="java.util.Arrays$ArrayList">
      <a class="profile-array">
        <profile id="0">
          <name>Guest</name>
          <deniedRequests class="java.util.Arrays$ArrayList">
            <a class="string-array">
              <string>CreateRoom</string>
              <string>PrivateMessage</string>
              <string>SetRoomVariables</string>
              <string>SetUserVariables</string>
              <string>ChangeRoomName</string>
              <string>ChangeRoomPassword</string>
              <string>ChangeRoomCapacity</string>
              <string>InitBuddyList</string>
              <string>AddBuddy</string>
              <string>BlockBuddy</string>
              <string>RemoveBuddy</string>
              <string>SetBuddyVariables</string>
              <string>GoOnline</string>
              <string>BuddyMessage</string>
              <string>ModeratorMessage</string>
              <string>AdminMessage</string>
              <string>KickUser</string>
              <string>BanUser</string>
            </a>
          </deniedRequests>
          <permissionFlags/>
        </profile>
        <profile id="1">
          <name>Standard</name>
          <deniedRequests class="java.util.Arrays$ArrayList">
            <a class="string-array">
              <string>ModeratorMessage</string>
              <string>AdminMessage</string>
              <string>KickUser</string>
              <string>BanUser</string>
            </a>
          </deniedRequests>
          <permissionFlags class="java.util.Arrays$ArrayList">
            <a class="string-array">
              <string>ExtensionCalls</string>
            </a>
          </permissionFlags>
        </profile>
        <profile id="2">
          <name>Moderator</name>
          <deniedRequests class="java.util.Arrays$ArrayList">
            <a class="string-array">
              <string>AdminMessage</string>
            </a>
          </deniedRequests>
          <permissionFlags class="java.util.Arrays$ArrayList">
            <a class="string-array">
              <string>ExtensionCalls</string>
              <string>SuperUser</string>
            </a>
          </permissionFlags>
        </profile>
        <profile id="3">
          <name>Administrator</name>
          <deniedRequests/>
          <permissionFlags class="java.util.Arrays$ArrayList">
            <a class="string-array">
              <string>ExtensionCalls</string>
              <string>SuperUser</string>
            </a>
          </permissionFlags>
        </profile>
      </a>
    </profiles>
  </privilegeManager>
  <extension>
    <name>ChakravestExtension</name>
    <type>JAVA</type>
    <file>com.chakravest.game.extension.ChakravestApplicationExtension</file>
    <propertiesFile></propertiesFile>
    <reloadMode>AUTO</reloadMode>
  </extension>
  <buddyList active="false">
    <allowOfflineBuddyVariables>true</allowOfflineBuddyVariables>
    <maxItemsPerList>100</maxItemsPerList>
    <maxBuddyVariables>15</maxBuddyVariables>
    <offlineBuddyVariablesCacheSize>500</offlineBuddyVariablesCacheSize>
    <customStorageClass></customStorageClass>
    <useTempBuddies>true</useTempBuddies>
    <buddyStates class="java.util.Arrays$ArrayList">
      <a class="string-array">
        <string>Available</string>
        <string>Away</string>
        <string>Occupied</string>
      </a>
    </buddyStates>
    <badWordsFilter isActive="true"/>
  </buddyList>
  <databaseManager active="true">
    <driverName>com.mysql.jdbc.Driver</driverName>
    <connectionString>jdbc:mysql://localhost:3306/mysql</connectionString>
    <userName>root</userName>
    <password>admin</password>
    <testSql>select * from People</testSql>
    <maxActiveConnections>10</maxActiveConnections>
    <maxIdleConnections>10</maxIdleConnections>
    <exhaustedPoolAction>FAIL</exhaustedPoolAction>
    <blockTime>3000</blockTime>
  </databaseManager>
</zone>


Configuration files of smartfox server

After installing smartfox server, you will find some configuration files in smartfox installation directory. In my case my installation directory is D:\projects\SmartFoxServer2X

Go to D:\projects\SmartFoxServer2X\SFS2X\config

Here you will find server.xml with smartfox configuration. This file is used by smartfox server when it is accessed in the browser. Iam listing the contents of the file here . Make sure you are using the ip in the <socketAddresses> tag. Please avoid to use 127.0.0.1. This file has those details that can be overriden via
http://10.0.3.74:8080/admin/ .  Please see this image



<serverSettings>
  <socketAddresses>
    <socket address="10.0.3.74" port="9933" type="TCP"/>
  </socketAddresses>
  <ipFilter>
    <addressBlackList>
      <string>1.2.3.4</string>
    </addressBlackList>
    <addressWhiteList>
      <string>127.0.0.1</string>
      <string>10.0.2.155</string>
    </addressWhiteList>
    <maxConnectionsPerAddress>9999999</maxConnectionsPerAddress>
  </ipFilter>
  <flashCrossdomainPolicy>
    <useMasterSocketPolicy>true</useMasterSocketPolicy>
    <policyXmlFile>crossdomain.xml</policyXmlFile>
  </flashCrossdomainPolicy>
  <systemControllerThreadPoolSize>1</systemControllerThreadPoolSize>
  <extensionControllerThreadPoolSize>3</extensionControllerThreadPoolSize>
  <systemControllerRequestQueueSize>20000</systemControllerRequestQueueSize>
  <extensionControllerRequestQueueSize>20000</extensionControllerRequestQueueSize>
  <schedulerThreadPoolSize>3</schedulerThreadPoolSize>
  <protocolCompressionThreshold>1024</protocolCompressionThreshold>
  <protocolMode>BINARY</protocolMode>
  <useBinaryProtocol>true</useBinaryProtocol>
  <remoteAdmin>
    <administrators>
      <adminUser>
        <login>sfsadmin</login>
        <password>sfsadmin</password>
      </adminUser>
    </administrators>
    <allowedRemoteAddresses/>
    <adminTcpPort>-1</adminTcpPort>
  </remoteAdmin>
  <bannedUserManager>
    <isAutoRemove>true</isAutoRemove>
    <isPersistent>true</isPersistent>
    <customPersistenceClass></customPersistenceClass>
  </bannedUserManager>
  <mailer>
    <isActive>false</isActive>
    <mailHost>test.mail.com</mailHost>
    <mailUser>foo</mailUser>
    <mailPass>pippo</mailPass>
    <smtpPort>25</smtpPort>
    <workerThreads>1</workerThreads>
  </mailer>
  <webServer>
    <isActive>true</isActive>
    <cfgFile>config/jetty/jetty.xml</cfgFile>
    <blueBoxPollingTimeout>26</blueBoxPollingTimeout>
    <blueBoxMsgQueueSize>40</blueBoxMsgQueueSize>
  </webServer>
  <webSocket>
    <isActive>false</isActive>
    <bindAddress>127.0.0.1</bindAddress>
    <tcpPort>8888</tcpPort>
    <validDomains/>
  </webSocket>
  <startExtensionFileMonitor>true</startExtensionFileMonitor>
  <useDebugMode>true</useDebugMode>
  <extensionRemoteDebug>true</extensionRemoteDebug>
  <useFriendlyExceptions>true</useFriendlyExceptions>
  <sessionMaxIdleTime>50</sessionMaxIdleTime>
  <userMaxIdleTime>300</userMaxIdleTime>
  <licenseCode></licenseCode>
  <licenseEmails></licenseEmails>
  <ghostHunterEnabled>false</ghostHunterEnabled>
  <statsExtraLoggingEnabled>false</statsExtraLoggingEnabled>
  <enableSmasherController>false</enableSmasherController>
</serverSettings>


We have another file located in the same folder config that is core.xml and the contents are listed below. These settings are used by smartfox server for initialization process

<coreSettings>
<systemControllerClass>com.smartfoxserver.v2.controllers.SystemController</systemControllerClass>
<extensionControllerClass>com.smartfoxserver.v2.controllers.ExtensionController</extensionControllerClass>
<ioHandlerClass>com.smartfoxserver.v2.protocol.DefaultIoHandler</ioHandlerClass>
<sessionManagerClass>it.gotoandplay.alt.AltSessionManager</sessionManagerClass>
<packetQueuePolicyClass>it.test.PacketQueueClass</packetQueuePolicyClass>
<readBufferType>Heap</readBufferType>
<writeBufferType>Heap</writeBufferType>

<!-- Editable settings -->

<!-- Max size of incoming packet -->
<maxIncomingRequestSize>8000000</maxIncomingRequestSize>

<!-- Max Size for read buffer -->
<maxReadBufferSize>1024</maxReadBufferSize>

<!-- Max Size for write buffer -->
<maxWriteBufferSize>32768</maxWriteBufferSize>

<!-- Session Queue Size -->
<sessionPacketQueueSize>160</sessionPacketQueueSize>

<!-- Thread Pool Size of the 3 main stages of the Bitswarm Engine -->
<socketAcceptorThreadPoolSize>1</socketAcceptorThreadPoolSize>
<socketReaderThreadPoolSize>1</socketReaderThreadPoolSize>
<socketWriterThreadPoolSize>1</socketWriterThreadPoolSize>

<!-- Enable disable Nagle algorithm on sockets, true == disable -->
<tcpNoDelay>true</tcpNoDelay>

<!-- BlueBox Settings -->
<bbMaxLogFiles>10</bbMaxLogFiles>
<bbMaxLogFileSize>5000000</bbMaxLogFileSize>
<bbDebugMode>false</bbDebugMode>

</coreSettings>

 Here we also find log4j.properties file. These are basic settings found in the config folder.

Tuesday, June 18, 2013

Smart Fox Server Installation


SmartFox server is widely used for multiplayer games. It can be easily integrated with different technologies like Apache Flex, Unity 3D, Android, IOS, Java , WIndows and C++. SmartFoxServer comes with a rich set of features, an impressive documentation set, tens of examples with their source, powerful administration tools and a very active support forum

Download SmartFox server from www.smartfoxserver.com

» SmartFoxServer 2X Installation

The installation of the SmartFoxServer 2X platform is a very simple operation that requires only a few steps. We recommend to review the system requirements and proceed consulting the specific installation guide for the operating system of your choice.

» System Requirements

SFS2X is a truly multi-platform solution supporting all major operating systems capable of running the Sun/Oracle Java Virtual Machine (JVM). This includes Windows (all versions), Linux, Mac OS X (10.5+) and other Unix variants.
In order to evaluate and develop with SFS2X you just need 64MB of free memory and a 1.0Ghz processor. For production environments we recommend a machine with at least 512MB of physical RAM and a 2.0Ghz processor.

Installing under Windows Installing under Linux Installing under Mac OS X Installing under other Unix variants A step-by-step video tutorial showing how to install SmartFoxServer is also available in our YouTube channel.

RUNNING SFS2X IN THE CLOUD

If you want to deploy SmartFoxServer 2X "in the cloud" (Amazon EC2 environment for example), you may consider using the RightScale platform. RightScale offers an advanced system for virtual servers management based on what they call ServerTemplates. We created a specific template which takes care of installing and configuring SFS2X automatically: in a few click you can have a SmartFoxServer instance up and running at no cost (except those of the cloud environment itself) and without having to deal with the installation and configuration tasks described in this page.
You can watch an introductory overview on SmartFoxServer 2X in the RightScale platform by accessing this video in our YouTube channel.
Also, detailed informations on the SFS2X ServerTemplate are available on the following pages: - Introduction to the SmartFoxServer 2X ServerTemplate - ServerTemplate detailed information and operations runbook

» Post-installation tasks

After the installation your SFS2X instance is ready to be started. By default the server binds exclusively the localhost IP address (127.0.0.1) on the default TCP port 9933. This will enable you to immediately test the server locally without worrying of security problems. Only your local machine will be able to talk to the server initially.
In order to begin your evaluation just start the server and point your browser to http://localhost:8080. This will bring up the welcome page referencing the Administration Tool and some example applications.

» Local firewall settings

If you have any problems accessing the server locally we recommend to check the settings of your personal firewall (every recent OS today provides one). You should make sure that traffic for TCP port 9933 is allowed bidirectionally.
» Exposing the server to the local network
In order to allow other computers in the LAN to access your SFS2X instance you will have to configure the server to listen on your private LAN address. Launch the Administration Tool, choose the Server Configurator module in the sliding Administration modules panel on the left and add one or more local addresses to the list of bound IPs.


Click on the Add button. The list of available IP addresses will be auto-detected and presented in the dropdown. Select one of the available addresses, and leave the the other values to default (unless you need to change port number). Finally hit Submit and restart the server.

» Exposing the server to the outside world
In order to make the server available publicily over the internet you will probably need the help of a router and setup port-forwarding, also known as NAT service. If your server hardware is directly connected to the internet this step is not necessary and you can skip this section entirely.
Setting up the NAT on your router will allow you to map your public IP address and port to the physical machine inside your network that runs the service (SFS2X in this case). In other words when the router will receive data on TCP port 9933 (SFS2X default) it will redirect those packets to the machine in your LAN running SmartFox.
A specific step-by-step guide on how to configure your router cannot be provided here because each brand and model differs from the others. We highly recommend to check the documentation coming with your router and follow their instructions. Typically it's a very quick operation that can be done via a convenient control panel.
If you are unsure about what your public address is, simply check this website. For more help on port forwarding we also suggest this website.

FINAL NOTE All the examples provided with SFS2X are pre-configured to connect to 127.0.0.1:9933 (the localhost). In order to use them when your server is exposed in the LAN or the internet you will have to change the IP address in the xml configuration file (usually called sfs-config.xml) bundled with each example.

» SFS2X setup on a remote server

In order to setup SmartFoxServer 2X on a remote machine, for example an Amazon EC2 instance, after the installation you have to make some manual changes to the configuration before being able to access the Administration Tool. You should follow these steps: locate and open (in a text editor) the main SFS2X xml configuration file: {sfs-install-dir}/SFS2X/config/server.xml; under the tag, substitute the 127.0.0.1 address with the private IP address of yor server (alternatively you can leave the localhost and add a new entry for the private IP); make sure that the list have no entries (delete them if necessary), then save the changes; check the firewall settings: you have to allow communication over ports 8080 and 9933 (at least); start SmartFoxServer 2X, open a browser and type http://your-public-ip:8080 to have access to the page which links the Administration Tool and some examples (please notice that the examples won't work – see the previous note); open the AdminTool, enter the public IP of the server in the host field and the default username/password: you should now have access to your SFS instance.