Events, PubNub and Storyboard

Hi.

I’m wondering about the best way to handle an event just before a Storyboard scene is changing!?

Currently I’m disconnecting from PubNub in a buttonBack() funtion, and on Android I then don’t see the device disconnecting from the specific channel? On iOS it works fine. I’ve adjusted the scene transition time and it seems to fix the problem:

function buttonBack()     disconnectFromPubnub(myGlobalData.currentPubnubChannel)     audio.play(sfx\_Select)     storyboard.gotoScene( "screenStart", "crossFade", 600  )     return true end  

Earlier I used 300ms and the I didn’t see Android devices disconnecting!?

Has this something to do with in the “enterScene” in “screenStart” i purge/remove this scene i’m comming from. Maybe the function gets halted before it can exeute??

Any toughts??

Frode

Ok so I changed my tactics.

My new approach is to use a global storage space, so I can cross reference variables throughout different modules within the app.

So I have a lua file called “myGlobalData.lua” which I include in all my Storyboard scenes.

Previously I only used this file for cross reference variables which I use different places in my game.

But after this “challenge” I added some functions to this file as showed below:

------------------------------------------------------------------------------------------------------------------------------------ -- Setup a global storage space, so we can cross reference variables throughout -- different modules within the app. ------------------------------------------------------------------------------------------------------------------------------------ local M = {} require "pubnub" M.pubnub = pubnub.new({ publish\_key = "pub-c-cxxx", subscribe\_key = "sub-c-xxx", secret\_key = "sec-c-xxx", ssl = nil, origin = "pubsub.pubnub.com", }) function M.disconnect(channel) M.pubnub:unsubscribe({ channel = channel, }) print('Disconnected from '.. channel) end return M  

After doing this I’m able to call the “disconnect” function from where ever I like without worrying about scenes closing before the function returns.

Frode

Ok so I changed my tactics.

My new approach is to use a global storage space, so I can cross reference variables throughout different modules within the app.

So I have a lua file called “myGlobalData.lua” which I include in all my Storyboard scenes.

Previously I only used this file for cross reference variables which I use different places in my game.

But after this “challenge” I added some functions to this file as showed below:

------------------------------------------------------------------------------------------------------------------------------------ -- Setup a global storage space, so we can cross reference variables throughout -- different modules within the app. ------------------------------------------------------------------------------------------------------------------------------------ local M = {} require "pubnub" M.pubnub = pubnub.new({ publish\_key = "pub-c-cxxx", subscribe\_key = "sub-c-xxx", secret\_key = "sec-c-xxx", ssl = nil, origin = "pubsub.pubnub.com", }) function M.disconnect(channel) M.pubnub:unsubscribe({ channel = channel, }) print('Disconnected from '.. channel) end return M  

After doing this I’m able to call the “disconnect” function from where ever I like without worrying about scenes closing before the function returns.

Frode