AppWarpS2 WP8 Quiz Tutorial demo server exception

0 votes
Many thanks for your reply, I'm getting a null pointer at the server end when both users logout on the quiz demo and not sure why?

RE: http://forum.shephertz.com/?qa=3772/appwarps2-wp8-quiz-tutorial-demo-connection-fail

Please see console print below...

Unable to locate tools.jar. Expected to find it in C:\Program Files\Java\jre8\li
b\tools.jar
Buildfile: C:\Users\Trip Admin\Desktop\Submissions\Verses Mode\Quiz_WindowsPhone
\Quiz_WindowsPhone\QuizServer\warp.xml
     [echo] Using Java version 1.8.

clean:
   [delete] Deleting directory C:\Users\Trip Admin\Desktop\Submissions\Verses Mo
de\Quiz_WindowsPhone\Quiz_WindowsPhone\QuizServer\build

compile:
    [mkdir] Created dir: C:\Users\Trip Admin\Desktop\Submissions\Verses Mode\Qui
z_WindowsPhone\Quiz_WindowsPhone\QuizServer\build\classes
    [javac] Compiling 21 source files to C:\Users\Trip Admin\Desktop\Submissions
\Verses Mode\Quiz_WindowsPhone\Quiz_WindowsPhone\QuizServer\build\classes
    [javac] warning: [options] bootstrap class path not set in conjunction with
-source 1.7
    [javac] 1 warning

jar:
    [mkdir] Created dir: C:\Users\Trip Admin\Desktop\Submissions\Verses Mode\Qui
z_WindowsPhone\Quiz_WindowsPhone\QuizServer\build\jar
      [jar] Building jar: C:\Users\Trip Admin\Desktop\Submissions\Verses Mode\Qu
iz_WindowsPhone\Quiz_WindowsPhone\QuizServer\build\jar\quizserver.jar

run:
     [java] Zone Created GOT_Quiz with key 8c2dcf00-0686-43bd-b
     [java] Room Created GOT_Quiz_Room1 with ID 647227785
     [java] Add user request jul
     [java] Room Created QuizRoom jul with ID 383274819
     [java] jul joined room Request
     [java] jul joined room Request Success
     [java] Received Start Quiz Packet1RoomId 383274819
     [java] Add user request emu
     [java] emu joined room Request
     [java] emu joined room Request Success
     [java] Received Start Quiz Packet2RoomId 383274819
     [java] Send Question Packet of 512
     [java] Sending Question to User jul
     [java] Sending Question to User emu
     [java] Answer Received 0
     [java] Send Answer
     [java] Answer Received 0
     [java] Send Answer
     [java] Send Answer
     [java] Send Answer
     [java] Send Question Packet of 512
     [java] Sending Question to User jul
     [java] Sending Question to User emu
     [java] QuizRoomAdaptor onUserLeaveRequest emu left room 383274819
     [java] QuizZoneAdaptor onUserRemoved jul
     [java] QuizRoomAdaptor onUserLeaveRequest jul left room 383274819
     [java] QuizZoneAdaptor onUserRemoved emu
     [java] java.lang.NullPointerException
     [java]     at java.util.Collections$UnmodifiableCollection.<init>(Unknown S
ource)
     [java]     at java.util.Collections$UnmodifiableList.<init>(Unknown Source)

     [java]     at java.util.Collections.unmodifiableList(Unknown Source)
     [java]     at com.shephertz.app42.server.domain.Room.getJoinedUsers(Room.ja
va:941)
     [java]     at quizserver.QuizRoomAdaptor.onTimerTick(Unknown Source)
     [java]     at com.shephertz.app42.server.domain.Room.handleTimerTick(Room.j
ava:857)
     [java]     at com.shephertz.app42.server.domain.Zone.handleTimerTick(Zone.j
ava:802)
     [java]     at com.shephertz.app42.server.handler.WarpProtocolHandler.handle
TimerTick(WarpProtocolHandler.java:539)
     [java]     at com.shephertz.app42.server.handler.LoopTask.run(WarpProtocolH
andler.java:676)
     [java]     at java.util.TimerThread.mainLoop(Unknown Source)
     [java]     at java.util.TimerThread.run(Unknown Source)
     [java] Deleting Room 383274819 true

 

Thanks
asked Sep 25, 2014 in AppWarpS2 by wiredvoltage (84 points)

1 Answer

+1 vote
 
Best answer
Hi,
 
Please update the onTimerTick method of QuizRoomAdaptor.
 
public void onTimerTick(long time) {
        /*
         * A game when room full
         * or we can say max users are equals to joined users
         * Once the game has started it will send question on every 10 seconds
         */
       try {
        if (HasAnyUserLeftTheRoom) {
            HasAnyUserLeftTheRoom=false;
            System.out.println("Deleting Room " + this.gameRoom.getId() + " " + this.izone.deleteRoom(gameRoom.getId()));
            gameRoom=null;
            GAME_STATUS = QuizConstants.STOPPED;
        }
        if (gameRoom!=null&&GAME_STATUS == QuizConstants.STOPPED && gameRoom.getJoinedUsers().size() == gameRoom.getMaxUsers() && gameRoom.getMaxUsers() == StartQuizFlag) {
            GAME_STATUS = QuizConstants.RUNNING;
            QuizTimerCount=Utils.LevelJson.getJSONObject(GameCurrentLevel).getInt("timePerQuestion") * 2-1;
            StartQuizFlag = 0;
        } else if (gameRoom!=null&&GAME_STATUS == QuizConstants.RUNNING) {
            QuizTimerCount++;
           
                if (GameCurrentLevel < Utils.LevelJson.length()) {
                    int timeCount = Utils.LevelJson.getJSONObject(GameCurrentLevel).getInt("timePerQuestion") * 2;
                    if (QuizTimerCount == timeCount) {
                        int totalQuestion = Utils.LevelJson.getJSONObject(GameCurrentLevel).getInt("totalQuestions");
                        if (GameCurrentQuestion != -1) {
                                AddDefaultAnswers();
                            }
                        if (GameCurrentQuestion < (totalQuestion - 1)) {
                            SendQuestion();
                        } else {
                            SendLevelEndPacket();
                        }
                    }
                }
            }
        }
        catch (Exception e) {
                e.printStackTrace();
            }
    }
answered Sep 26, 2014 by errahulpanchal (169 points)
selected Sep 26, 2014 by wiredvoltage
Many thanks, I'll implement this later today.
Is the server demo complete
Download Widgets
Welcome to ShepHertz Product line forum, where you can ask questions and receive answers from the community. You can also reach out to us on support@shephertz.com
...