Serialization in smartfox

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

Moderators: Lapo, Bax

veeru.srinivas
Posts: 11
Joined: 31 Jul 2013, 09:08

Serialization in smartfox

Postby veeru.srinivas » 04 Sep 2013, 05:56

Hi,

I am new to Smartfox server. I am developing a turn based game using Smartfoxsever. I am able to run application for two players it means single room
I am unable to write extension for dynamic room creation at server side .Please suggest the approach or provide source code...


Thanks & Regards

Veeru
Last edited by veeru.srinivas on 20 Nov 2013, 12:46, edited 1 time in total.
User avatar
Lapo
Site Admin
Posts: 23008
Joined: 21 Mar 2005, 09:50
Location: Italy

Re: Room creation

Postby Lapo » 04 Sep 2013, 08:16

Hi Veeru,
writing an extension is pretty simple. You can follow this video tutorial:
http://www.youtube.com/watch?v=nKGxhwJ0Ccc

And of course there's tons more in our documentation mini-site:
http://docs2x.smartfoxserver.com/Develo ... extensions
http://docs2x.smartfoxserver.com/Develo ... ension-api

Hope it helps
Lapo
--
gotoAndPlay()
...addicted to flash games
veeru.srinivas
Posts: 11
Joined: 31 Jul 2013, 09:08

Re: Room creation

Postby veeru.srinivas » 04 Sep 2013, 12:36

Hi,

Thanks for reply!!!!

I am having idea of creation of extensions i have created an application which is able handle single room i wanna help regarding Dynamic room creation..

Thanks
veeru.
User avatar
rjgtav
Posts: 2813
Joined: 19 Apr 2009, 11:31
Location: Lisbon, Portugal

Re: Room creation

Postby rjgtav » 10 Sep 2013, 02:43

Hi,

I'm sorry but you have to provide further details.
When do you want to create those new rooms dinamically?

In the meantime, you can check the SFSApi class of the Java Server API Documentation, as it contains the createRoom() methods which are responsible for creating a room whenever you want.

Cheers
Skills: SFS Pro, SFS2X, AS2.0/AS3.0, Java, HTML5/CSS3/JS, C#
Portfolio: https://rjgtav.wordpress.com/
SFS Tutorials: http://sfs-tutor.blogspot.com/ - Discontinued. Some examples may be bugged.
veeru.srinivas
Posts: 11
Joined: 31 Jul 2013, 09:08

Re: Room creation

Postby veeru.srinivas » 10 Sep 2013, 07:11

Hi,

Thanks a lot for reply !!

Now i got the idea of dealing with dynamic room creation

Thanks & Regards
Veeru
veeru.srinivas
Posts: 11
Joined: 31 Jul 2013, 09:08

Serialization in smartfox

Postby veeru.srinivas » 20 Nov 2013, 10:44

Hi,

I am trying to use smartfox server serialization concept which was given in ..http://docs2x.smartfoxserver.com/Advanc ... alization..
I am able to send data to the client side but while receiving data from client to server side java i am getting "Error deserializing request: com.smartfoxserver.v2..." classNotfound exception . I have followed all the steps given in sfs2x documentation... please provide me solution.

Thanks in Advance,
Regards ,
Veeru.
User avatar
Lapo
Site Admin
Posts: 23008
Joined: 21 Mar 2005, 09:50
Location: Italy

Re: Room creation

Postby Lapo » 20 Nov 2013, 10:47

Please post the full stack trace of the exception and also specify which client API language you are using.
Also post the code of the classes that you are sending, at least the one that is failing to deserialize.

Thanks
Lapo

--

gotoAndPlay()

...addicted to flash games
veeru.srinivas
Posts: 11
Joined: 31 Jul 2013, 09:08

Re:serialization problem in smartfox

Postby veeru.srinivas » 20 Nov 2013, 12:35

Hi ,

I am using Java for server side and AS3 for client side.

This is i am finding in my logs :
17:27:29,648 WARN [SocketReader] protocol.SFSProtocolCodec - Error deserializing request: com.smartfoxserver.v2.exceptions.SFSRuntimeException: java.lang.ClassNotFoundException: sfs2x.extension.test.serialization.model.WaterFloodSpell

After this nothing is executed..


Java code:
package sfs2x.extension.test.serialization.model;

import com.smartfoxserver.v2.protocol.serialization.SerializableSFSType;

public class WaterFloodSpell implements SerializableSFSType
{
String id;
int hitPoints;
int count = 7;

public WaterFloodSpell()
{

}
public WaterFloodSpell(String id, int hitPoints)
{
this.id = id;
this.hitPoints = hitPoints;
}

public String getId()
{
return id;
}
public void setId(String id)
{
this.id = id;
}
public int getHitPoints()
{
return hitPoints;
}
public void setHitPoints(int hitPoints)
{
this.hitPoints = hitPoints;
}

public void setCount(int count)
{
this.count = count;
}
public int getCount()
{
return count;
}


}



AS3 Code:

Code: Select all

package sfs2x.extension.test.serialization.model
{
    import com.smartfoxserver.v2.protocol.serialization.SerializableSFSType
 
    public class WaterFloodSpell implements  SerializableSFSType
    {
        private var _id:String
        private var _hitPoints:int
        private var _count:int
     
        public function WaterFloodSpell(id:String=null, hitPoints:int=70)
        {
            this._id = id
            this._hitPoints = hitPoints
        }
     
        public function get id():String
        {
            return _id
        }
         
        public function set id(id:String):void
        {
            this._id = id
        }
         
        public function get hitPoints():int
        {
            return _hitPoints
        }
         
        public function set hitPoints(hitPoints:int):void
        {
            this._hitPoints = hitPoints
        }
         
        public function get count():int
        {
            return _count
        }
         
        public function set count(value:int):void
        {
            _count = value
        }
 
       
    }
}

Thanks & Regards
Veeru.
veeru.srinivas
Posts: 11
Joined: 31 Jul 2013, 09:08

Re: Serialization in smartfox

Postby veeru.srinivas » 25 Nov 2013, 06:43

Hi,

I am waiting for reply i have posted the information.. Am i doing any wrong...?


Thanks,
Veeru.
User avatar
Lapo
Site Admin
Posts: 23008
Joined: 21 Mar 2005, 09:50
Location: Italy

Re: Serialization in smartfox

Postby Lapo » 25 Nov 2013, 08:45

In order for the model classes to be found by the SFS deserializer they need to be deployed in the extension/__lib__/ folder.

All the details are explained in the documentation:
http://docs2x.smartfoxserver.com/Advanc ... ialization
See the "Deploying the Extension" section at the bottom.

Hope it helps
Lapo

--

gotoAndPlay()

...addicted to flash games
veeru.srinivas
Posts: 11
Joined: 31 Jul 2013, 09:08

Re: Serialization in smartfox

Postby veeru.srinivas » 28 Nov 2013, 06:30

Hi,

Thanks for reply !!!!! Its working fine ...
could you pls provide the tris game java server side source code.
Regards,
Veeru.
User avatar
Lapo
Site Admin
Posts: 23008
Joined: 21 Mar 2005, 09:50
Location: Italy

Re: Serialization in smartfox

Postby Lapo » 28 Nov 2013, 08:03

The server code is already provided with the example.

cheers
Lapo

--

gotoAndPlay()

...addicted to flash games

Return to “SFS2X Questions”

Who is online

Users browsing this forum: No registered users and 45 guests