Page 1 of 1
android tris example - room doesn't exist exception
Posted: 13 Nov 2012, 16:02
by GrandFunk
I'm using the android tris example application.
I can create a room game but when I'll try to connect by another emulator i got a room doesn't exist exception:
Code: Select all
13 Nov 2012 | 14:26:33,916 | WARN | com.smartfoxserver.v2.controllers.SystemController-1 | v2.controllers.SystemController | |
com.smartfoxserver.v2.exceptions.SFSJoinRoomException: Join Error - Requested room doesn't exist
com.smartfoxserver.v2.api.SFSApi.joinRoom(SFSApi.java:810)
com.smartfoxserver.v2.api.SFSApi.joinRoom(SFSApi.java:691)
com.smartfoxserver.v2.controllers.system.JoinRoom.execute(JoinRoom.java:83)
com.smartfoxserver.v2.controllers.SystemController.processRequest(SystemController.java:128)
com.smartfoxserver.bitswarm.controllers.AbstractController.run(AbstractController.java:96)
java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886)
java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908)
java.lang.Thread.run(Thread.java:662)
Re: android tris example - room doesn't exist exception
Posted: 19 Nov 2012, 16:43
by Lapo
Sorry for the delay.
Can you give us more details as how this happens? The original Tris example shouldn't cause that error.
thanks
Re: android tris example - room doesn't exist exception
Posted: 21 Nov 2012, 23:14
by GrandFunk
Here are the detailed steps I executed:
I downloaded Android Exmple Pack:
http://www.smartfoxserver.com/download/get/112
in eclipse:
file -> import
Android -> Existing Android Code Into Workspace
Root Directory AndSFS/Tris/source/client
copy projects into workspace
Finish
----
downloaded android API:
http://www.smartfoxserver.com/download/get/133
----
cd workspace/sfs2x.example.android.tris.Tris/lib
rm -f *.jar
cp jar API previously downloaded to lib
cd ..
mv lib libs
----
in eclipse
Refresh lib directory
Projct->Properties->Java Build Path-> Libraries
removed existings jar (red) and added jars in libs
in Tris.java and TrisGame.java
removed @Override
because I had errors in eclipse
-----
copyed deploy/extensions in SmartFoxServer2X/SFS2X/extensions
started Server
----
started 2 client Application
P.S.: My OS is ArchLinux
Re: android tris example - room doesn't exist exception
Posted: 22 Nov 2012, 09:39
by Lapo
in Tris.java and TrisGame.java
removed @Override
because I had errors in eclipse
This is strange. Are you using at least the JDK 1.6? Sounds like you are using an older version.
Re: android tris example - room doesn't exist exception
Posted: 22 Nov 2012, 10:39
by GrandFunk
Lapo wrote:
This is strange. Are you using at least the JDK 1.6? Sounds like you are using an older version.
OpenJDK 7
Re: android tris example - room doesn't exist exception
Posted: 22 Nov 2012, 10:44
by Lapo
And what would be the problem with the @Overrides exactly?
Re: android tris example - room doesn't exist exception
Posted: 22 Nov 2012, 10:49
by Lapo
UPDATE: I think JDK 7 is probably the cause in the case of Android:
http://stackoverflow.com/questions/8757 ... on-jdk-7u2
Read the first anser.
In any case I doubt that it's the cause of the problem.
A join error simply indicates that you are trying to join a Room that doesn't exist on the server. In order to test with two players you need to launch two instances, start one game and then join it with the second player.
BTW: can you launch two android emulators? As far as I can remember when I player a little with the SDK it was not possible.
thanks
Re: android tris example - room doesn't exist exception
Posted: 22 Nov 2012, 11:06
by GrandFunk
Lapo wrote:And what would be the problem with the @Overrides exactly?
I do not remember now.
I'll be more specific this evening, I have not the pc with the application now.
Lapo wrote:A join error simply indicates that you are trying to join a Room that doesn't exist on the server. In order to test with two players you need to launch two instances, start one game and then join it with the second player.
I have launched two instances in two emulators.
started one game with first player.
With the second emulator I have seen the game in game list.
But when I have clicked on list item I have Room doesn't exist error on the server log.
Re: android tris example - room doesn't exist exception
Posted: 22 Nov 2012, 11:09
by GrandFunk
[quote="Lapo" ]can you launch two android emulators? As far as I can remember when I player a little with the SDK it was not possible.
[/quote]
I have to created two emulator and run it seperately.
in Run Configuration. Goto -> Target -> Select manual Target.
When I run the project its automatically ask the device selector.
Re: android tris example - room doesn't exist exception
Posted: 22 Nov 2012, 12:00
by GrandFunk
it is possible that the room appears in GameList before it has been created on the server?
If so could be the cause of the bug.
This evening I'll try to wait several seconds before clicking on the item
Re: android tris example - room doesn't exist exception
Posted: 22 Nov 2012, 19:50
by GrandFunk
GrandFunk wrote:Lapo wrote:
This is strange. Are you using at least the JDK 1.6? Sounds like you are using an older version.
OpenJDK 7
ok, I understand your question only now, sorry.
I went to Project-> Property-> Compiler Compliance Level and I set 1.6 (default was 1.5).
So the override problem is solved.
Maybe specify this in the tutorial may help others who have found themselves in my situation.
regarding the error "room does not exist" I made other tests, experiencing that, if after creating the game expect several seconds before the second player to join, then everything works fine.
So how can fix it?
Re: android tris example - room doesn't exist exception
Posted: 28 Nov 2012, 08:49
by Lapo
Maybe you're not listening for the ROOM_ADD event.
You can create a Room a join it immediately by passing autoJoin=true as the 2nd parameter in the request, (check CreateRoomRequest for the details)
Otherwise you can do this in two steps:
Create the Room.
Join the Room when the user receives the ROOM_ADD event
hope it helps
Re: android tris example - room doesn't exist exception
Posted: 02 Dec 2012, 08:52
by GrandFunk
I'm using tris example downloaded from smartfoxsrver site.
Lapo wrote:Maybe you're not listening for the ROOM_ADD event.
ROOM_ADD event listener exists.
In Tris.java:
Code: Select all
sfsClient.addEventListener(SFSEvent.ROOM_ADD, this);
[...]
@Override
public void dispatch(final BaseEvent event) throws SFSException
{
runOnUiThread(new Runnable() {
@Override
public void run() {
else if(event.getType().equalsIgnoreCase(SFSEvent.ROOM_ADD) || event.getType().equalsIgnoreCase(SFSEvent.ROOM_REMOVE))
{
updateGameList();
Room thisRoom = (Room)event.getArguments().get("room");
appendChatMessage(event.getType() + ": [" + thisRoom.getName() + "] \n");
//Enables the chat UI
enableChatUI();
}
Lapo wrote:
You can create a Room a join it immediately by passing autoJoin=true as the 2nd parameter in the request, (check CreateRoomRequest for the details)
second parameter in CreateRoomRequest seems to be already true:
in Tris.java class:
Code: Select all
sfsClient.send( new CreateRoomRequest(settings, true, sfsClient.getLastJoinedRoom()));