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.