Weird multiple connections

0 votes

Hi. Before i start i have to say that my english level isn't as good as many of you. So i apologise for that.

I am making a videogame which have a real-time multiplayer mode. I have done this part recently.

When it is the first time that the two devices connect to the server, they can play really nice and well. Once one of them is defeated their screens go back to the main menu. Then when those two devices want to do another game (quick game, random players) things get really weird. I'll explain what it does the first device that want to play another quick game.

  • Tries to do 2 connections (like if they did a "connectWithUserName" twice. Totally impossible because it's in the constructor of the screen)
  • Tries to connect 4 different rooms (totally weird), then creates those 4 rooms (the System.out.println show me that this occurs 4 times each room. -> 16 connections)
  • Result -> 16 failed to getLiveUserInfo What am i doing wrong? I disconnected incorrectly from the server the previous time?

What i do to disconnect:

  • warpClient.leaveRoom()
  • onLeaveRoomDone() -> warpClient.unSubscribeRoom()
  • onUnSubscribeRoomDone() -> warpClient.disconnect()
  • onDisconnectDone() -> disposeListeners()

Thanks.

asked Apr 6, 2016 in Java by Domingo Garcia (10 points)

1 Answer

0 votes
Hi Domingo,

There are some steps which can be performed only once on app start such as:

-Connecting to the server using connectWithUserName

-Adding listeners

And in that case there is no need to disconnect and dispose listeners after every game over, you only have to make sure that listener object which you have added must be alive.

In your case you can only perform leave + unsubscribe the room on game over and join+subscribe the room on game start.

Please try this and let me know if it helps.

Thanks.
answered Apr 7, 2016 by rajeev.etc (1,660 points)
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
...