SmartFoxServer API (key classes and Key Interfaces)


SmartfoxServer2x programing can be divided into server related programing, client related programing.

As mentioned earlier to this session Extension are fundamental units of smartfoxserver2x, through the extension programing we can control the zone and rooms.

Extension Life Cycle:-

  • Extension is a java program so in the same way, Extension program have a life cycle as extension initialization done at init() method and ends at destroy() method.
  • init() whenever the extension loaded into Smartfox this will be fired, during the lifespan of extension it is fired only once.
  • destroy() this method is fired while at the time of extension close/kill.

SmartfoxServer2X provides an API with that we can create the extension jar files. Key Classes of Smartfox/Extension API

Key Classes And Interfaces of SmartFoxServer2X API

  • We can create the zones manually by creating zone.xml files under zones folder
  • We can create the zones using SmartfoxAdminTool in easy GUI manner.
  • Simple code to create room from Server side:
  • Simple code to create room at Client side:
Sno Class/Interface Description
1 ISFSExtension Root Interface which consists the methods of extension life cycle to implement.
2 IServerEventHandler
3 IClientRequestHandler
4 SFSExtension An abstract class which implements ISFSExtension , If we want to call a java program as Extension File then it must extend this class.

Main Methods of this class are

  • init()
  • destroy()
  • addEventHandler()
  • addRequestHandler()
  • handleServerRequest()
  • handleClientRequest()
5 BaseServerEventHandler
  • An Abstract class which Implements IClientRequestHandler
  • If we want to handle the custom events means non-predefined events then our class need to extend this class.
  • This abstract class consist an abstract method named handleClientRequest() we need to implement that method.
6 BaseClientRequestHandler
  • In order to override the behaviour of predefined events related zone and room we need to extend this class.
  • Means if we want to handle the events like Zonejoin, RoomJoin, Login, Disconnect in that case our class must extend BaseServerRequestHandler.
  • This abstract class consist an abstract method named handleServerEvent() we need to implement that method.
7 SFSEventType
  • This is an enum which consist EventTypes supported and generated by SmartfoxServer
8 SmartFoxServer
  • Main class of Extension api, Only after instantiation of this class only all the other smartfox related program able to interact with client.
  • A static method named 'getInstance()' of this class return the instance of SmartFoxServer.
9 SFSDBManager
  • It is a class which implements IDBManager interface provided by SFS2X platform.
  • It manages 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.
  • Each Zone runs its own DbManager which can be configured via the Zone Configurator module in the SFS2X AdminTool.
  • A Zone can instantiate multiple DbManagers via server side code.
  • Key Methods of SFSDBManager
    • Connection getConnection()
    • Object executeInsert()
    • void executeUpdate()
    • ISFSArray executeQuery()
    • int getActiveConnections()
    • int getIdleConnections()
Copyright © 2018-2020 TutorialToUs. All rights reserved.