custom login revisited
custom login revisited
Hi
I have 2 problems that I have no clue how to solve on the new format for custom login:
1) My clients need to send additional information when logging in and the server should act upon it. So my client will send the game version for instance, and the server will check that version and reply with an Upgrade if required.
Is there a way to send this version information on login from the client side?
How can the server reply with a "UP" (upgrade) message? I thought about using SFSErrorData but I don't see how to put that information in there. What type should it be? LOGIN_BAD_ZONENAME?
In any case I guess I have to throw a SFSLoginException somehow right?
2) Check for addtional login errors. On version 1.x I could so a simple helper.canLogin and I will get a true or false. Then check some stuff: server full? room full? etc... and act accordingly. Then inform the client that they were not able to login or fix the issue before I send reponse to the client.
I don't see a way to do this on 2.0. After I handle all my 'ifs' on custom login, if the server has a problem with this person (user already logged in?) I have no way of knowing it since the detection will happen after my code is done.
Regards,
Joaqui
I have 2 problems that I have no clue how to solve on the new format for custom login:
1) My clients need to send additional information when logging in and the server should act upon it. So my client will send the game version for instance, and the server will check that version and reply with an Upgrade if required.
Is there a way to send this version information on login from the client side?
How can the server reply with a "UP" (upgrade) message? I thought about using SFSErrorData but I don't see how to put that information in there. What type should it be? LOGIN_BAD_ZONENAME?
In any case I guess I have to throw a SFSLoginException somehow right?
2) Check for addtional login errors. On version 1.x I could so a simple helper.canLogin and I will get a true or false. Then check some stuff: server full? room full? etc... and act accordingly. Then inform the client that they were not able to login or fix the issue before I send reponse to the client.
I don't see a way to do this on 2.0. After I handle all my 'ifs' on custom login, if the server has a problem with this person (user already logged in?) I have no way of knowing it since the detection will happen after my code is done.
Regards,
Joaqui
Is there a way to send this version information on login from the client side?
Yes check the docs, the login request supports extra custom params, and from server side you can do the same (custom response data)
I don't see a way to do this on 2.0. After I handle all my 'ifs' on custom login, if the server has a problem with this person (user already logged in?) I have no way of knowing it since the detection will happen after my code is done.
server full? room full?
The Room example is not correct maybe you mean Zone full.
Anyways, yes you are right, you are not notified of errors. We saw little use in this actually but if necessary we might add an extra error event in the future.
Can you describe exactly what kind of different things could you do based on login errors? Typically a user login fails if he's banned (and this is already handled via customizable message), if the username contains swear words (again customizable) or if the server is full... etc...
In the case of a server full you would typically react from client side, not server side.
Ok by points...
1) I saw the documentation but there is no example except for the "you can send custom data!" ok... how?
On the client side... no example.
On the server side... I see a LOGIN_OUT_DATA that would send out custom data, but that it's send after a positive login. Meaning, it's not thrown as an exception and I can to cancel the login.
If I put the data under something like LOGIN_BAD_ZONENAME or whatever, I went into the client side, unity3d, I did a loop through all the keys/values on the returned error and my strings were not there. So I don't see a way to send something to the client that:
a) The server sends out something like "i don't like you, period". And stops the login process.
b) The client can get that error and display: motivo!: "i don't like you, period"
I tried every possible combination but unity doesn't get any of the strings I send back unless it's on a LOGIN_OUT_DATA... which again, that's out only if login was successful. correct?
2) Well, I would like to know why the server would block someone before it's blocked. For instance... already logged in. If that's the case, the server can kick the old connection out and continue the process like nothing.
Also, I don't see a example on Unity3D on how to detect the messages the login sends back. For instance, LOGIN_BAD_USERNAME or LOGIN_BAD_ZONENAME
On the method OnLoginError, I checked the parameters and I see a text string with content, but nothing that seem to allow me to do a
if (evt.id = login_bad_username) display this
else if (evt.id = login_bad_zonename) display that
and so on. At least I can't find them on examples.
Thanks
1) I saw the documentation but there is no example except for the "you can send custom data!" ok... how?
On the client side... no example.
On the server side... I see a LOGIN_OUT_DATA that would send out custom data, but that it's send after a positive login. Meaning, it's not thrown as an exception and I can to cancel the login.
If I put the data under something like LOGIN_BAD_ZONENAME or whatever, I went into the client side, unity3d, I did a loop through all the keys/values on the returned error and my strings were not there. So I don't see a way to send something to the client that:
a) The server sends out something like "i don't like you, period". And stops the login process.
b) The client can get that error and display: motivo!: "i don't like you, period"
I tried every possible combination but unity doesn't get any of the strings I send back unless it's on a LOGIN_OUT_DATA... which again, that's out only if login was successful. correct?
2) Well, I would like to know why the server would block someone before it's blocked. For instance... already logged in. If that's the case, the server can kick the old connection out and continue the process like nothing.
Also, I don't see a example on Unity3D on how to detect the messages the login sends back. For instance, LOGIN_BAD_USERNAME or LOGIN_BAD_ZONENAME
On the method OnLoginError, I checked the parameters and I see a text string with content, but nothing that seem to allow me to do a
if (evt.id = login_bad_username) display this
else if (evt.id = login_bad_zonename) display that
and so on. At least I can't find them on examples.
Thanks
1)
The login process is described here:
http://docs2x.smartfoxserver.com/Develo ... ogin-phase
including the extra params. The login request is self explanatory.
Also check the server side java doc for more details on the server event(s)
2)
This is a particular feature that we'll implement in the server API, doing it manually with the current API might lead to insuccess. Handling a disconnection and quick reconnection requires a low level control over the sockets.
The login process is described here:
http://docs2x.smartfoxserver.com/Develo ... ogin-phase
including the extra params. The login request is self explanatory.
Also check the server side java doc for more details on the server event(s)
2)
Well, I would like to know why the server would block someone before it's blocked. For instance... already logged in. If that's the case, the server can kick the old connection out and continue the process like nothing.
This is a particular feature that we'll implement in the server API, doing it manually with the current API might lead to insuccess. Handling a disconnection and quick reconnection requires a low level control over the sockets.
Lapo, for 1) the problem I'm having is with the client side. On the website this is all I can find:
public function onLoginError(evt:SFSEvent):void
{
trace("Login failed: " + evt.params.errorMessage);
}
But I need to know, of the different type of login errors that the server can throw out, how can I detect each?
On the .net library I can't find anything on the client side that would allow me to identify the error type.
I'm looking for a simple:
if (evt.type == badpassword) do this
else if (evt.type == serverfull) do that
On the server I see LOGIN_BAD_PASS as a enum, but I can't find that on the client side. Neither an example on how to handle different types of login errors on the client side.
public function onLoginError(evt:SFSEvent):void
{
trace("Login failed: " + evt.params.errorMessage);
}
But I need to know, of the different type of login errors that the server can throw out, how can I detect each?
On the .net library I can't find anything on the client side that would allow me to identify the error type.
I'm looking for a simple:
if (evt.type == badpassword) do this
else if (evt.type == serverfull) do that
On the server I see LOGIN_BAD_PASS as a enum, but I can't find that on the client side. Neither an example on how to handle different types of login errors on the client side.
Ok I give an example of what I mean. On the server I have this code:
SFSErrorData errData = new SFSErrorData(SFSErrorCode.LOGIN_BAD_ZONENAME); // we'll use this of all kind of errors
errData.addParameter("UP");
// Fire a Login exception
throw new SFSLoginException("UP", errData);
So, I go to the client thinking I'll get something with that content, and I print out every single value on the object. This is what I get:
evt.Type = loginError (ok...? i was expecting something like LOGIN_BAD_ZONENAME but ok...)
evt.Target = target:Sfs2X.SmartFox (go figure...)
evt.Params[success]=false (one that makes sense!)
evt.Params[errorMessage]: Requested Zone: UP does not exist.
that's it. I was hopping for a Params["UP"] somewhere, since I attached that to the server exception. Or an "UP" somewhere since SFSLoginException is created with that... but I see no "UP" alone in anything, it's mixed in between the errorMessage.
SFSErrorData errData = new SFSErrorData(SFSErrorCode.LOGIN_BAD_ZONENAME); // we'll use this of all kind of errors
errData.addParameter("UP");
// Fire a Login exception
throw new SFSLoginException("UP", errData);
So, I go to the client thinking I'll get something with that content, and I print out every single value on the object. This is what I get:
evt.Type = loginError (ok...? i was expecting something like LOGIN_BAD_ZONENAME but ok...)
evt.Target = target:Sfs2X.SmartFox (go figure...)
evt.Params[success]=false (one that makes sense!)
evt.Params[errorMessage]: Requested Zone: UP does not exist.
that's it. I was hopping for a Params["UP"] somewhere, since I attached that to the server exception. Or an "UP" somewhere since SFSLoginException is created with that... but I see no "UP" alone in anything, it's mixed in between the errorMessage.
Hi,
I'm trying to implement something similar, with little success.
Test 1
I get
Test 2
I get
As far as I can tell, the replace {0} to param is not getting done. I'm using server [ 2.0.0-RC2a ] and the latest Java Client.[/code]
I'm trying to implement something similar, with little success.
Test 1
Code: Select all
errData = new SFSErrorData(SFSErrorCode.GENERIC_ERROR);
errData.addParameter("INVALID_VERSION");
throw new SFSLoginException("INVALID_VERSION", errData);
I get
Code: Select all
Login Failed : ['errorMessage'->'{0}'|'success'->false]
Test 2
Code: Select all
errData = new SFSErrorData(SFSErrorCode.GENERIC_ERROR);
List<String> errInfo = new ArrayList<String>();
errInfo.add("INVALID_VERSION");
errData.setParams(errInfo);
throw new SFSLoginException("INVALID_VERSION", errData);
I get
Code: Select all
Login Failed : ['errorMessage'->'{0}'|'success'->false]
As far as I can tell, the replace {0} to param is not getting done. I'm using server [ 2.0.0-RC2a ] and the latest Java Client.[/code]
creat326
I would suggest to use a GENERIC_ERROR type code and add to it a custom string that contains any parameter that you need to react to the situation.
You could also use separators in the String to provide several params, if you need them.
Sample server-side pseudocode:
On the client you grab that via:
creat326
From the string passed as errorMessage param
That string is fully customizable and you can replace it with a code if you wish. More here:
viewtopic.php?t=9324&start=0&postdays=0&postorder=asc&highlight=sfserrorcode
I would suggest to use a GENERIC_ERROR type code and add to it a custom string that contains any parameter that you need to react to the situation.
You could also use separators in the String to provide several params, if you need them.
Sample server-side pseudocode:
Code: Select all
errData = new SFSErrorData(SFSErrorCode.GENERIC_ERROR)
errData.addParameter("Mydata,maybe,with,separated,params")
throw new SFSLoginException("MyGebericError", errData )
On the client you grab that via:
Code: Select all
private function onLoginError(evt:SFSEvent):void
{
trace("Login Failure: " + evt.params.errorMessage)
}
creat326
But I need to know, of the different type of login errors that the server can throw out, how can I detect each?
From the string passed as errorMessage param
That string is fully customizable and you can replace it with a code if you wish. More here:
viewtopic.php?t=9324&start=0&postdays=0&postorder=asc&highlight=sfserrorcode
Lets try this again:
My first test case was:
It's virtually identical to what you wrote. When I get the output, I print out the value of the parameter
and I get an output of : {0}
I mentioned that I am using the Java API. There is no params member of an SFSEvent, just an argument. In addition, the {0} seems a placeholder for something. Is this a bug?
Cheers,
Alex
My first test case was:
Code: Select all
errData = new SFSErrorData(SFSErrorCode.GENERIC_ERROR);
errData.addParameter("INVALID_VERSION");
throw new SFSLoginException("INVALID_VERSION", errData);
It's virtually identical to what you wrote. When I get the output, I print out the value of the parameter
Code: Select all
if (event.getType().equals(SFSEvent.LOGIN_ERROR)) {
System.out.println(event.getArguments().get("errorMessage");
}
and I get an output of : {0}
I mentioned that I am using the Java API. There is no params member of an SFSEvent, just an argument. In addition, the {0} seems a placeholder for something. Is this a bug?
Cheers,
Alex
-
- Posts: 1297
- Joined: 14 Mar 2008, 07:52
- Location: Sweden
Put onto the buglist!
Full Control - maker of Unity/C# and Java SFS API and indie games
Follow on twitter: http://twitter.com/thomas_h_lund
Follow on twitter: http://twitter.com/thomas_h_lund
-
- Posts: 1297
- Joined: 14 Mar 2008, 07:52
- Location: Sweden
And its fixed in SVN now. So part of next release
/Thomas
/Thomas
Full Control - maker of Unity/C# and Java SFS API and indie games
Follow on twitter: http://twitter.com/thomas_h_lund
Follow on twitter: http://twitter.com/thomas_h_lund
Who is online
Users browsing this forum: Baidu [Spider] and 133 guests