Duplicate instances of openSpace?

Post here your questions about the OpenSpace 2.x or notify bugs and suggestions.

Moderators: Lapo, Bax

croftie
Posts: 32
Joined: 24 Jul 2013, 08:35
Location: Algarve Portugal
Contact:

Duplicate instances of openSpace?

Postby croftie » 18 Sep 2014, 11:08

The scenario here is that I want players to start as a guest by default and then have them login or register later (to save progress).

When a player wishes to login or register it is necessary to logout the guest account and then log them back in. In this case Openspace resets and so I removed all openspace listeners and removed it as child (it is dynamically instantiated in as3) and then null it before the logout. Then logout request is made. I then create a new instance of openspace and add all listeners and addchild etc.

On a new login event the openspace instance is initialized. The problem is that I can see from [info] traces that the initialisation process is called twice. My trace is below:

Code: Select all

openSpace Added
sending login as guest
Main Class onLogin
Successfully logged in so now OpenSpace can be initialized and a map loaded
initialise Openspace
[INFO] Configuration loaded: /CCounter/config/OpenSpace_client.xml
[INFO] Requesting initialization data to OpenSpace Extension
[INFO] Initialization data received from OpenSpace Extension
[INFO] Initialization completed
OpenSpace.INITIALIZED event received - load map lobby
[INFO] Requesting map to OpenSpace Extension
[INFO] Map received from OpenSpace Extension
[INFO] Map parsing completed (11 ms)
Map loaded, now assets swf files can be loaded
furniture.swf backgrounds.swf
External libraries loaded, now the loaded map can be rendered
[INFO] Tiles creation progress: 13%
[INFO] Tiles creation progress: 27%
[INFO] Tiles creation progress: 40%
[INFO] Tiles creation progress: 100%
[INFO] Map generation completed (101 ms)
[INFO] Map rendering duration: 15 ms
[INFO] Map shifted
[INFO] Map rendering duration: 2 ms
[INFO] Map shifted
[INFO] Avatar '17' created in (1,6,0)
[INFO] Avatars creation completed
[INFO] Map rendering completed
creating Login Form
openspace removed and nulled
logout request sent
openSpace Added
sending login request
Main Class onLogin
Successfully logged in so now OpenSpace can be initialized and a map loaded
initialise Openspace
[INFO] Configuration loaded: /CCounter/config/OpenSpace_client.xml
[INFO] Requesting initialization data to OpenSpace Extension
[INFO] Configuration loaded: /CCounter/config/OpenSpace_client.xml
[INFO] Requesting initialization data to OpenSpace Extension
[INFO] Initialization data received from OpenSpace Extension
[INFO] Initialization completed
[INFO] Initialization data received from OpenSpace Extension
[INFO] Initialization completed
OpenSpace.INITIALIZED event received - load map lobby
[INFO] Requesting map to OpenSpace Extension
[INFO] Initialization data received from OpenSpace Extension
[INFO] Initialization completed
[INFO] Initialization data received from OpenSpace Extension
[INFO] Initialization completed
OpenSpace.INITIALIZED event received - load map lobby
[INFO] Requesting map to OpenSpace Extension
[ERROR] OpenSpace Extension is unable to load the map: Unable to join requested Room (id:1). Join Error - User already joined: ( User Name: Guest#18, Id: 18, Priv: 0, Sess: 192.168.1.66:53082 ) , Room: [ Room: Lobby, Id: 1, Group: default, isGame: false ], Zone: { Zone: BJ_Card_Counter } (0090)
[ERROR] OpenSpace Extension is unable to load the map: Unable to join requested Room (id:1). Join Error - User already joined: ( User Name: Guest#18, Id: 18, Priv: 0, Sess: 192.168.1.66:53082 ) , Room: [ Room: Lobby, Id: 1, Group: default, isGame: false ], Zone: { Zone: BJ_Card_Counter } (0090)
OpenSpace.MAP_ERROR event received:
0090 - OpenSpace Extension is unable to load the map: Unable to join requested Room (id:1). Join Error - User already joined: ( User Name: Guest#18, Id: 18, Priv: 0, Sess: 192.168.1.66:53082 ) , Room: [ Room: Lobby, Id: 1, Group: default, isGame: false ], Zone: { Zone: BJ_Card_Counter }
[INFO] Map received from OpenSpace Extension
[INFO] Map parsing completed (2 ms)
[INFO] Map received from OpenSpace Extension
Error: Error #2058: There was an error decompressing the data.
   at flash.utils::ByteArray/_uncompress()
   at flash.utils::ByteArray/uncompress()
   at com.smartfoxserver.openspace.engine.control::OpenSpaceController2X/onExtensionResponse()
   at flash.events::EventDispatcher/dispatchEventFunction()
   at flash.events::EventDispatcher/dispatchEvent()
   at com.smartfoxserver.v2.controllers::ExtensionController/handleMessage()
   at com.smartfoxserver.v2.core::SFSProtocolCodec/dispatchRequest()
   at com.smartfoxserver.v2.core::SFSProtocolCodec/onPacketRead()
   at com.smartfoxserver.v2.core::SFSIOHandler/handlePacketData()
   at com.smartfoxserver.v2.core::SFSIOHandler/onDataRead()
   at com.smartfoxserver.v2.bitswarm::BitSwarmClient/onSocketData()


It seems to me that the first instance of openspace is still in existence. Any suggestions?
User avatar
Bax
Site Admin
Posts: 4332
Joined: 29 Mar 2005, 09:50
Location: Italy
Contact:

Re: Duplicate instances of openSpace?

Postby Bax » 25 Sep 2014, 13:01

I'm not sure why the instance still exists and what is retaining from being removed by the garbage collector.
Anyway why don't you keep using the same instance, instead of destroying it (apparently) and adding again all the listeners and more?
Paolo Bax
The SmartFoxServer Team

Return to “OpenSpace v2 discussions and help”

Who is online

Users browsing this forum: No registered users and 4 guests