Moderator, Admin, Standard, etc.
Moderator, Admin, Standard, etc.
Hi. Today i was trying the isModerator, isAdmin and isStandardUser methods and realized that all returned false, even loggin with admin's username and password. And curiously the only one that returned true was isGuest, but i'm not loging in as a guest... Am i doing something wrong during the login phase or this feature isnt implemented yet?
BTW i can't find where to define the moderators, only the admin.
BTW i can't find where to define the moderators, only the admin.
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.
Portfolio: https://rjgtav.wordpress.com/
SFS Tutorials: http://sfs-tutor.blogspot.com/ - Discontinued. Some examples may be bugged.
you need to look at the privilige manager in the docs, when you logged in a user you will need to assign the group in the onjoinzone handler.
you need to store the permission profile Id in the Session properties but i got stuck on the retrieval of the group id when i needed to assign the group.
i have not had a chance yet to work more on it.
you need to store the permission profile Id in the Session properties but i got stuck on the retrieval of the group id when i needed to assign the group.
i have not had a chance yet to work more on it.
Thanks 
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.
Portfolio: https://rjgtav.wordpress.com/
SFS Tutorials: http://sfs-tutor.blogspot.com/ - Discontinued. Some examples may be bugged.
So... I have already configured the privilege manager, before joining the lobby I set the user's privilege id to the one given from the database (via server extension). In the AdminTool it shows the correct privilegeID/profileID (in this case is 2 that means the user is a Moderator). But when i check with user.isModerator(), it still returns false and saying that the user is a Guest... What am I missing?
BTW, the privilege Manager is working. For example if i deny the moderator to send public messages, it doesnt let it send.
[UPDATE]
For some reason, the other players can see that this user is moderator when they join into the lobby or when the moderator joins in...
BTW, the privilege Manager is working. For example if i deny the moderator to send public messages, it doesnt let it send.
[UPDATE]
For some reason, the other players can see that this user is moderator when they join into the lobby or when the moderator joins in...
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.
Portfolio: https://rjgtav.wordpress.com/
SFS Tutorials: http://sfs-tutor.blogspot.com/ - Discontinued. Some examples may be bugged.
I have exactly the same problem.rjgtav wrote:
For some reason, the other players can see that this user is moderator when they join into the lobby or when the moderator joins in...
Every client gets the right privilege ID except the user where the privilige id is assigned to, and set the ID manually doesn't work clientside either
doesn't make any difference if the users are allready logged in, or logged in after the "moderator". only the holder off the privilege id doesnt get it right.
Flex, Smartfoxserver, red5. and Linux Why does microsoft still exist?
Hi. My profiles are the default ones. 0-Guest, 1-Standard, 2-Moderator and 3-Administrator. And yes, the login is handled by Extension code. and it successfully sets the correct privilegeId, retrieved from the database.
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.
Portfolio: https://rjgtav.wordpress.com/
SFS Tutorials: http://sfs-tutor.blogspot.com/ - Discontinued. Some examples may be bugged.
Yup.
here's the code BTW:
here's the code BTW:
Code: Select all
public class JoinEventHandler extends BaseServerEventHandler
{
@Override
public void handleServerEvent(ISFSEvent event) throws SFSJoinRoomException
{
trace("<-JOIN ZONE EVENT->");
trace("joining room");
Zone zone = SmartFoxServer.getInstance().getZoneManager().getZoneByName(Main.ZONE);
Room room = zone.getRoomByName("Lobby");
User user = (User) event.getParameter(SFSEventParam.USER);
ISFSApi smartfox = SmartFoxServer.getInstance().getAPIManager().getSFSApi();
ISession session = user.getSession();
SFSObject userInfo = (SFSObject) session.getProperty("userInfo");
trace("privlegeID: "+(Short.parseShort((userInfo.getUtfString("privilege")).trim())));
user.setPrivilegeId(Short.parseShort((userInfo.getUtfString("privilege")).trim()));
List<UserVariable> vars = new ArrayList<UserVariable>();
vars.add(new SFSUserVariable("lv",userInfo.getUtfString("lv")));
vars.add(new SFSUserVariable("country",userInfo.getUtfString("country")));
smartfox.setUserVariables(user, vars);
trace("room: "+room);
trace("user: "+user);
smartfox.joinRoom(user, room);
}
}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.
Portfolio: https://rjgtav.wordpress.com/
SFS Tutorials: http://sfs-tutor.blogspot.com/ - Discontinued. Some examples may be bugged.
Ok, gotcha.
The problem is that the USER_JOIN_ZONE is "too late". The login response has already been sent to the User and that one contains the privilegeID for the client API.
There's a trick for this, and I am sorry to say we haven't documented this yet, because it's quite advanced. I will make sure that a note is added in the Login tutorials about this.
You need to set the profileID in the USER_LOGIN event, by storing it as a property in the Session object. The convention requires that the property key is called --> $permission.
This is the code:
Of course, if you are working with privilege ID other than the default ones you will first need to create a Class/Enum that implements the IPermissionProfile interface and that describe the new permission id(s);
Example:
Hope it helps
The problem is that the USER_JOIN_ZONE is "too late". The login response has already been sent to the User and that one contains the privilegeID for the client API.
There's a trick for this, and I am sorry to say we haven't documented this yet, because it's quite advanced. I will make sure that a note is added in the Login tutorials about this.
You need to set the profileID in the USER_LOGIN event, by storing it as a property in the Session object. The convention requires that the property key is called --> $permission.
This is the code:
Code: Select all
session.setProperty("$permission", DefaultPermissionProfile.MODERATOR);
Example:
Code: Select all
public enum JediPermissionProfile implements IPermissionProfile
{
JEDI_INITIATE(4),
JEDI_PADAWAN(5),
JEDI_KNIGHT(6),
JEDI_MASTER(7);
private JediPermissionProfile(int id)
{
this.id = (short) id;
}
private short id;
public short getId()
{
return id;
}
}K. BTW, i'm working with the default ones, i only store them in a database. I'll try that later. Thanks
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.
Portfolio: https://rjgtav.wordpress.com/
SFS Tutorials: http://sfs-tutor.blogspot.com/ - Discontinued. Some examples may be bugged.
Can i use session.setProperty("$permission", theIdOfThePermissionProfile); instead?
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.
Portfolio: https://rjgtav.wordpress.com/
SFS Tutorials: http://sfs-tutor.blogspot.com/ - Discontinued. Some examples may be bugged.
Ok thanks again. That turns this much easier
[EDIT]
Ups. i thought that i could use session.setProperty("$permission", 2) instead of session.setProperty("$permission", DefaultPermissionProfile.MODERATOR) but i've already seen that i can't
[EDIT]
Ups. i thought that i could use session.setProperty("$permission", 2) instead of session.setProperty("$permission", DefaultPermissionProfile.MODERATOR) but i've already seen that i can't
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.
Portfolio: https://rjgtav.wordpress.com/
SFS Tutorials: http://sfs-tutor.blogspot.com/ - Discontinued. Some examples may be bugged.
is there a better way than using this?
Code: Select all
Short privilegeId = Short.parseShort((userData.getUtfString("PRIVILEGE")).trim());
if(privilegeId == 0){
session.setProperty("$permission", DefaultPermissionProfile.GUEST);
}else if(privilegeId == 1){
session.setProperty("$permission", DefaultPermissionProfile.STANDARD);
}else if(privilegeId == 2){
session.setProperty("$permission", DefaultPermissionProfile.MODERATOR);
}else if(privilegeId == 3){
session.setProperty("$permission", DefaultPermissionProfile.ADMINISTRATOR);
}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.
Portfolio: https://rjgtav.wordpress.com/
SFS Tutorials: http://sfs-tutor.blogspot.com/ - Discontinued. Some examples may be bugged.