Problem with switch userTemp for User

Need help with SmartFoxServer? You didn't find an answer in our documentation? Please, post your questions here!

Moderators: Lapo, Bax

obs
Posts: 9
Joined: 26 Aug 2009, 16:07

Problem with switch userTemp for User

Postby obs » 21 Sep 2009, 15:03

i writing the AS3 client and server in java ...
in my config.xml like this ...

Code: Select all

<Zone name="TestZone"  uCountUpdate="false" maxUsers="50" customLogin="false" emptyNames="true">
      
      <DisabledSysEvents>
             <event>onJoinRoom</event>
             <event>onRoomAdded</event>
             <event>onRoomDeleted</event>
             <event>onUserEnterRoom</event>
             <event>onSpectatorSwitched</event>
             <event>onUserCountChange</event>
             <event>onUserLeaveRoom</event>
             <event>onRoomLeft</event>
             <event>onRoomCreateError</event>
             <event>onJoinRoomError</event>
             <event>onRoundTripResponse</event>
             <event>onLogout</event>
        </DisabledSysEvents>

      <Rooms>
         <Room name="Lobby" autoJoin="true" limbo="true" maxUsers="50" uCount="false" />      
      </Rooms>
      
      <Extensions>
         <extension name="ExtensionTest" className="pk.controladores.ExtensionTest" type="java" />
      </Extensions>
      
</Zone>


when the swf loads the client has already automatically connects as a client temporary .. guest_X and join in lobby room.
swf on the client has a login button, where he puts the data and click send ... clicking the button, I send 1 msg pra extension response with the data. this works well.
Client side..

Code: Select all

public function sendLogin(e:MouseEvent):void
{
       var da:Array = new Array(2);
       da[0] = log_in.login_txt.text;
       da[1] = log_in.password_txt.text;
       sfs.sendXtMessage("ExtensionTest", "logar", da, "str");
}


Server side...

Code: Select all

public void handleRequest(String cmd, String params[], User u, int fromRoom){
if(cmd.equals("logar")){

                        Boolean ok = true;
         User newUser = null;

         String login = (params.length > 0)? params[0]:"";
         String senha = (params.length > 1)? params[1]:"";
         SocketChannel ch = u.getChannel();

         // Prepara estrutura de resposta para o cliente
         String[] res = new String[3];
                        // object handle BD
         UsuarioDAO usuarioBD = null;

         try {
            usuarioBD = new UsuarioDAO();
            trace("criou usuarioBD");
         } catch (Exception e1) {
            e1.printStackTrace();
         }

      if(login.equalsIgnoreCase("") || senha.equalsIgnoreCase("")){

            res[0] = "logKO";
            res[1] = "Login ou senha inválido.";
         }else{
            try{
// Return true if login and password is ok. TESTED!
ok = usuarioBD.checkLogin(login, senha);
            } catch (Exception e) {
               e.printStackTrace();
               ok = false;
            }
            if(ok){

               try{

// Get Lobby room for tests
Room lobby = curentZone.getRoom(lobbyId);
trace("max users in lobby room >>> " + lobby.getMaxUsers());
trace("count user in room >>> " + lobby.getUserCount());
// logout old user               
helper.logoutUser(u.getUserId(), false, false);
// get new user
newUser = helper.canLogin(login, senha, ch, zoneName);
// join new user in lobby room 
helper.joinRoom(newUser, -1, lobbyId, true, "", true, false);
               // organize response for client   
               res[0]= "logOK";
               res[1] =String.valueOf(newUser.getUserId());
               res[2] = newUser.getName();

               }catch(ExtensionHelperException e){
                  trace(e.getMessage());
                  trace("catch helper");
               } catch (LoginException e) {
                  trace("catch login");
                  trace(e.getMessage());
               }
            }else{
               res[0] = "logKO";
               res[1] = "error.";
            }
         }

   LinkedList<SocketChannel> ll = new LinkedList<SocketChannel>();
   ll.add(u.getChannel());
   sendResponse(res, -1, null, ll);

      }
   }



ERROR:
swf compiles usually temporary user enters the room but when he asks for login with another user ... the server says that the room is full ...

the method that throws the problem is a "helper.joinRoom(...)"
why I do not know...

Code: Select all

12:01:37.696 - [ INFO ] > Room Join Error: This room is currently full, User: teste, IP: 127.0.0.1


HELP!!!
User avatar
rjgtav
Posts: 2813
Joined: 19 Apr 2009, 11:31
Location: Lisbon, Portugal

Postby rjgtav » 21 Sep 2009, 16:06

Hi there. Why don't you just connect to the zone instead of loging in a room as a guest? In my game (for example) the client first connects to the zone to check if the server is on. If it is, the user puts the data and then login a room.
obs
Posts: 9
Joined: 26 Aug 2009, 16:07

Postby obs » 21 Sep 2009, 16:52

rjgtav wrote:Hi there. Why don't you just connect to the zone instead of loging in a room as a guest? In my game (for example) the client first connects to the zone to check if the server is on. If it is, the user puts the data and then login a room.


to load it already connects as guest ... where it is just a spectator.
but I want to implement the option of exchanging it for a real user that appears on my database. I have to make a change you know?
all logic implemented on the server side.

Return to “SmartFoxServer 1.x Discussions and Help”

Who is online

Users browsing this forum: No registered users and 109 guests