NullPointer in trace

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

Moderators: Lapo, Bax

Baiumka
Posts: 7
Joined: 04 Dec 2018, 09:57

NullPointer in trace

Postby Baiumka » 09 Jan 2019, 23:48

Hello, again =)

I have a problem with trace().

Code: Select all

public class IamReady extends BaseClientRequestHandler {
    @Override
    public void handleClientRequest(User sender, ISFSObject params) {

            trace("All users are ready");
            StartThisGame();
        }
       void StartThisGame(){
        Thread myThread = new Thread(new SendUnitData(),"SendUnitData");
        myThread.start();
    }
}

class SendUnitData extends IamReady implements Runnable {
    boolean runned = false;

    public void run() {
        runned = true;
        LetsDoThis();
    }

    void LetsDoThis() {
      try {
          trace("We go!");
      }
      catch (NullPointerException e)
      {
          e.printStackTrace();
      }
       
    }
}



Code: Select all

java.lang.NullPointerException
        at com.smartfoxserver.v2.extensions.BaseClientRequestHandler.trace(BaseClientRequestHandler.java:103)
        at GameExtension.SendUnitData.LetsDoThis(IamReady.java:42)
        at GameExtension.SendUnitData.run(IamReady.java:37)
        at java.lang.Thread.run(Unknown Source)


String number 42: trace("We go!");

What is a problem?
User avatar
Lapo
Site Admin
Posts: 20644
Joined: 21 Mar 2005, 09:50
Location: Italy

Re: NullPointer in trace

Postby Lapo » 11 Jan 2019, 09:14

Hi,
you posted under the wrong section (this is SFS2X, not SFS Pro/Basic 1.x), I have moved the thread.

What version of SFS2X are you using?
Why do you need to create a new thread to handle the request? The multi-threading work is already handled by the server, in most case you should not need to create new threads, plus this approach is quite inefficient to scale.

Thanks
Lapo
--
gotoAndPlay()
...addicted to flash games

Return to “SFS2X Questions”

Who is online

Users browsing this forum: No registered users and 8 guests