How To Set RoomExtension Response EventListener in Unity

Post here your questions about the Unity / .Net / Mono / Windows 8 / Windows Phone 8 API for SFS2X

Moderators: Lapo, Bax

User avatar
pogsdbest
Posts: 17
Joined: 08 Feb 2019, 10:09

How To Set RoomExtension Response EventListener in Unity

Postby pogsdbest » 08 Feb 2019, 10:19

Hi guys, i'm completely new to smartfoxserver , but searching my required topic in this forum is pretty hard.
i would like to ask how to listen to a specific room extension that i created. here's what i did. im using unity btw.

Code: Select all

   RoomSettings settings = new RoomSettings ( details.tableID );
        settings.GroupId = "table";
        settings.IsGame = true;
        settings.MaxUsers = 999;
        settings.MaxSpectators = 0;
       
        settings.Extension = new RoomExtension ( EXTENSION_ID, EXTENSION_CLASS );

        joinCallback = callback;
        sfs.AddEventListener ( SFSEvent.ROOM_JOIN, OnCreateTable );
        sfs.AddEventListener ( SFSEvent.ROOM_JOIN_ERROR, OnCreateTableError );

        sfs.Send ( new CreateRoomRequest ( settings, true ) );


after successfully creating the room and joined in. i set my listener to

Code: Select all

sfs..AddEventListener ( SFSEvent.EXTENSION_RESPONSE, OnExtensionResponse );


the code seems to work, i can received my extension response but the problem is. when i create multiple Rooms using the first code above.
every room that i created received the ExtensionResponse. i would like to ask how to listen on the Room that i just created and join. thank you.
User avatar
Lapo
Site Admin
Posts: 23025
Joined: 21 Mar 2005, 09:50
Location: Italy

Re: How To Set RoomExtension Response EventListener in Unity

Postby Lapo » 08 Feb 2019, 10:39

Hello,
the code seems to work, i can received my extension response but the problem is. when i create multiple Rooms using the first code above. every room that i created received the ExtensionResponse.

The code you use creates a Room and assigns the Extension you have chosen to it.
When the client calls the Extension you need to pass the Room parameter to specify which Room Extension you want to send the request to.
If you do this, only that specific Extension will get the request. If you don't specify any Room parameter, the request goes to the Zone Extension, if it exists.
i would like to ask how to listen on the Room that i just created and join. thank you.

You can use the SmartFox.LastJoinedRoom property to obtain a reference to the last joined Room.

Cheers
Lapo
--
gotoAndPlay()
...addicted to flash games
User avatar
pogsdbest
Posts: 17
Joined: 08 Feb 2019, 10:09

Re: How To Set RoomExtension Response EventListener in Unity

Postby pogsdbest » 08 Feb 2019, 11:16

thanks lapo, i think my mistake was not passing the Room that i created on the

Code: Select all

sfs.send(new ExtensionResponse(CMD,SFSObject,Room))

and all my Request to the extensions goes to the Zone. that's why every Room receives it.

Return to “SFS2X C# API”

Who is online

Users browsing this forum: No registered users and 22 guests