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

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

Get room extension instance

Postby shlapkoff » 04 Dec 2014, 20:46

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: 23008
Joined: 21 Mar 2005, 09:50
Location: Italy

Re: Get room extension instance

Postby Lapo » 05 Dec 2014, 09:39

[[ 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:
viewtopic.php?p=76126#p76126

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

Re: Get room extension instance

Postby shlapkoff » 05 Dec 2014, 10:41

Thanks for your help.

Return to “SFS2X Questions”

Who is online

Users browsing this forum: Google [Bot] and 60 guests