Room is full while joining room

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

Moderators: Lapo, Bax

nik0990
Posts: 76
Joined: 23 Dec 2016, 10:48
Location: India

Room is full while joining room

Postby nik0990 » 27 Mar 2017, 10:53

Hi,

I have a problem. While player joining room i am using this code.

Code: Select all

var onJoin = sfs.send(new SFS2X.Requests.System.JoinRoomRequest(roomName,null,null,true));


And when i see sfs.myself.isSpec() it show true but after take seat i am firing an event from server specToPlayer but client side not responding this as a player.
But sfs.myself.isSpec() it show false. What should i do.

Thanks in advance.
User avatar
Lapo
Site Admin
Posts: 23026
Joined: 21 Mar 2005, 09:50
Location: Italy

Re: Room is full while joining room

Postby Lapo » 27 Mar 2017, 11:22

Hi,
when you switch a spectator to player you will receive an event back.
Either SFSEvent.SPECTATOR_TO_PLAYER or SFSEvent.SPECTATOR_TO_PLAYER_ERROR

Make sure you add a listener for both in order to handle failures.

Thanks
Lapo
--
gotoAndPlay()
...addicted to flash games
nik0990
Posts: 76
Joined: 23 Dec 2016, 10:48
Location: India

Re: Room is full while joining room

Postby nik0990 » 27 Mar 2017, 11:34

Hi,

Thanks for reply.

But After room join sfs.myself.isSpec() is true and after take seat it become false.

But client side code not working acc. to player it is working like it is a spec.
User avatar
Lapo
Site Admin
Posts: 23026
Joined: 21 Mar 2005, 09:50
Location: Italy

Re: Room is full while joining room

Postby Lapo » 27 Mar 2017, 14:05

But After room join sfs.myself.isSpec() is true and after take seat it become false.

This is expected and it shows that entering as spectator and switching to a player works correctly.

But client side code not working acc. to player it is working like it is a spec.

Well, I am not sure what you mean by this...
The fact that the client side code is not working correctly depends on how your logic behaves based on the fact that a User is either a spectator or player.

In other words, the client code must react to those spectator/player switch events and enable/disable the features that are available to the two types of users.

Makes sense?
Lapo

--

gotoAndPlay()

...addicted to flash games
nik0990
Posts: 76
Joined: 23 Dec 2016, 10:48
Location: India

Re: Room is full while joining room

Postby nik0990 » 29 Mar 2017, 09:11

Hi Lapo,

I am not getting my User in sfs.lastJoinedRoom.getPlayerList() If player is spec.
nik0990
Posts: 76
Joined: 23 Dec 2016, 10:48
Location: India

Re: Room is full while joining room

Postby nik0990 » 29 Mar 2017, 09:14

Code: Select all

function onRoomJoin(msg){
    console.log(golden._dispatcher);
   roomJoined = true;
   SFSobj.roomName = msg.room.name;
   console.log('ROOM '+SFSobj.roomName+ " JOINED SUCCESSFULLY" );
   updateFooter();
   var footerUl = document.getElementById("footerUl");
   var html = "<li id="+SFSobj.roomName+"><a id=\"\" href=\"#\" onclick=toggle_visibility("+"'"+SFSobj.roomName+"'"+")>"+SFSobj.roomName+"</a></li>";
   $('#footerUl').append(html);
   //getting player id and saving it in parser model
   var room = sfs.lastJoinedRoom;
   var user = room.getPlayerList();
   console.log(user);
   for(var i=0;i<user.length;i++){
      //console.log(user[i]);
      if(user[i].isItMe){
         SFSobj.myPlayerId = user[i].getVariable("PlayerId").value;
      }
   }
   loader.style.display = 'block';
   //SFSobj.myPlayerId = sfs.mySelf.getPlayerId(sfs.lastJoinedRoom);
   golden._dispatcher.fireEvent(golden.connectionEventConstant.events.ROOM_JOIN_SUCCESS, SFSobj.myPlayerId);
}


This is my client side code and in user spec not showing.
User avatar
Lapo
Site Admin
Posts: 23026
Joined: 21 Mar 2005, 09:50
Location: Italy

Re: Room is full while joining room

Postby Lapo » 29 Mar 2017, 09:22

nik0990 wrote:Hi Lapo,

I am not getting my User in sfs.lastJoinedRoom.getPlayerList() If player is spec.

The getPlayerList() method will only return players, not every user in the Room.

You've got three different methods in a Room:

getUserList() --> returns all users
getPlayerList() -> returns all players
getSpectatorList() --> returns all spectators

Assuming you're using javascript on the client side, here's the doc
http://docs2x.smartfoxserver.com/api-do ... SRoom.html

cheers
Lapo

--

gotoAndPlay()

...addicted to flash games
nik0990
Posts: 76
Joined: 23 Dec 2016, 10:48
Location: India

Re: Room is full while joining room

Postby nik0990 » 29 Mar 2017, 09:48

Thanks

Issue resolved

Return to “SFS2X Questions”

Who is online

Users browsing this forum: No registered users and 98 guests