Get room extension instance

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

Moderators: Lapo, Bax

Post Reply
shlapkoff
Posts: 8
Joined: 24 Nov 2014, 11:02

Get room extension instance

Post by shlapkoff »

I have an inheritance:

Code: Select all

SPTeamDeathMatchExtension > SeaPiratesExtension > SFSExtension
I want to get an instance of extension room

Code: Select all

public class ListGameHandler extends BaseClientRequestHandler 
{
    @Override
    public void handleClientRequest(User u, ISFSObject data) 
    {  
        List<Room> roomList = this.getParentExtension().getParentZone().getRoomList();
        SFSArray gameRoomInfoList = new SFSArray();
        
        for (Room room : roomList) 
        {
            if (room.isGame())
            {
                SeaPiratesExtension tmpExt = (SeaPiratesExtension) room.getExtension();
            }
        }
    }
But I'm getting
Exception: java.lang.ClassCastException
Message: main.SPTeamDeathMatchExtension cannot be cast to main.SeaPiratesExtension
Description: Error while handling client request in extension: { Ext: seapirates, Type: JAVA, Lev: ROOM, { Zone: SeaPirates }, [ Room: TheLobby, Id: 0, Group: default, isGame: false ] }
What is wrong?
User avatar
Lapo
Site Admin
Posts: 23438
Joined: 21 Mar 2005, 09:50
Location: Italy

Re: Get room extension instance

Post by Lapo »

[[ Message was moved to the right section ]]

Hi,
the problem is due to class loading.
We have already discussed this aspect many times. See this reply for example:
http://forums.smartfoxserver.com/viewto ... 126#p76126

cheers
Lapo
--
gotoAndPlay()
...addicted to flash games
shlapkoff
Posts: 8
Joined: 24 Nov 2014, 11:02

Re: Get room extension instance

Post by shlapkoff »

Thanks for your help.
Post Reply