No Example or exaplanation for RoomStorageMode.DB_STORAGE

Post here your questions about SFS2X. Here we discuss all server-side matters. For client API questions see the dedicated forums.

Moderators: Lapo, Bax

stelarfox
Posts: 15
Joined: 06 Aug 2021, 14:33

No Example or exaplanation for RoomStorageMode.DB_STORAGE

Postby stelarfox » 09 Mar 2022, 20:27

Hello I am trying to implement a database version of te file storage and the closest that i could found is:

Code: Select all

            DbRoomConfiguration config = new DbRoomConfiguration();
            getParentZone().initRoomPersistence(RoomStorageMode.DB_CUSTOM, config);

where the DbRoomConfiguration is defined by:
public class DbRoomConfiguration extends BaseStorageConfig

Code: Select all

{
    public String connectionString;
    public String driverName;
    public String databaseName;
    public String tableName;
    DbRoomConfiguration() {
        connectionString = "jdbc:mysql://127.0.0.1:3306";
        driverName = "com.mysql.cj.jdbc.Driver";
        databaseName = "CARDS";
        tableName = "card";
        skipStaticRooms=false;
        storeInactiveRooms=true;
        storeRoomVariables=true;
    }
}

now the for public strings i set there, I got from a bad written example and i say bad written because is does not compile as .DB_CUSTOM is not allowed.
the only optionI have besides : RoomStorageMode.FILE_STORAGE is RoomStorageMode.DB_STORAGE, but hey, There is Nowhere to find how to config that option. And naturally if i try to just run it it fails to work.
I tried to investigate where to find the structure required and truly have no idea, because could not find ANY documentation about it on your site. Not saying there is not there but if it is, is not related to the DB_Storage or, your search engine on the help is not getting it. and no mention of it is there on the initRoomPersistence. Clearly i am new to using this form so, how should i look for it?
User avatar
Lapo
Site Admin
Posts: 23008
Joined: 21 Mar 2005, 09:50
Location: Italy

Re: No Example or exaplanation for RoomStorageMode.DB_STORAGE

Postby Lapo » 10 Mar 2022, 11:02

Hi,
The database-based Room storage system is already provided by the API you don't need to create your own custom class that extends BaseStorageConfig.

Under the package com.smartfoxserver.v2.persistence.room you find two main configuration classes:

  • FileRoomStorageConfig: for file-based storage
  • DBRoomStorageConfig: for the database-based storage
More details on each class is found in the server side javadoc. For example this is the DBRoomStorageConfig class:
http://docs2x.smartfoxserver.com/api-do ... onfig.html

By default the DBRoomStorageConfig uses the database configuration in your Zone, so you have to do is setting up the connection in your Zone setup (via the AdminTool)

Cheers
Lapo
--
gotoAndPlay()
...addicted to flash games
stelarfox
Posts: 15
Joined: 06 Aug 2021, 14:33

Re: No Example or exaplanation for RoomStorageMode.DB_STORAGE

Postby stelarfox » 10 Mar 2022, 11:53

Thanks the only problem is that, I truly did not find all that explanation anywhere. And thanks that explains all i needed to know.
User avatar
Lapo
Site Admin
Posts: 23008
Joined: 21 Mar 2005, 09:50
Location: Italy

Re: No Example or exaplanation for RoomStorageMode.DB_STORAGE

Postby Lapo » 10 Mar 2022, 15:59

If you check the javadoc for the class I mentioned it is stated that the configuration of the database is taken from the default Zone DB Manager.
In any case we'll revise the documentation with more details and a database example to clarify how to use this modality.

If there's anything else, let us know.

Cheers
Lapo

--

gotoAndPlay()

...addicted to flash games
User avatar
Lapo
Site Admin
Posts: 23008
Joined: 21 Mar 2005, 09:50
Location: Italy

Re: No Example or exaplanation for RoomStorageMode.DB_STORAGE

Postby Lapo » 10 Mar 2022, 16:42

UPDATE: the documentation has been updated
http://docs2x.smartfoxserver.com/Advanc ... stence-api

Cheers
Lapo

--

gotoAndPlay()

...addicted to flash games

Return to “SFS2X Questions”

Who is online

Users browsing this forum: No registered users and 56 guests