Facebook listener in another file

Hi guys,

I am trying to put the facebook listener in a seperate file from the caller.

Example :

Caller, main.lua   => Calls "facebook.login(  appId,  file2_listener, {“publish_stream”}  )

Listener, file2.lua    => It has a global function, ‘function file2_listener()’

So far, it only partly works, where only the ‘event.type=session’ gets processed. When i try calling facebook.request(“me”), it does not enter the listener anymore. It just stops after the ‘session’.

It works fine if the listener is in the same file as the caller. I tried this on corona’s sample code (Facebook), and place the facebook listener in another file. Same results, where it only partly works.

Anyone having this problem ? I see the advantage of having a central location to handle all facebook processing, instead of having a listener in every file (which uses facebook.login)

Thanks

@yosu, I actually have a single file where I have all the facebook related code that I access from all other scenes/files.  It looks something like this:

[lua]

– let’s name this file myFB.lua

local M = {}

local function listener1()

   – do what you want this listener to do

end

function M.login()

    facebook.login( appID, listener1, { “publish_actions”  } )

end

return M

[/lua]

And from other module I do this:

[lua]

local myFB = require(“myFB”)

myFB.login()

[/lua]

Naomi

thanks Naomi. Loos like the ‘facebook.login’ command  needs to be in the same file as the listener. I will give it a try.

@yosu, I actually have a single file where I have all the facebook related code that I access from all other scenes/files.  It looks something like this:

[lua]

– let’s name this file myFB.lua

local M = {}

local function listener1()

   – do what you want this listener to do

end

function M.login()

    facebook.login( appID, listener1, { “publish_actions”  } )

end

return M

[/lua]

And from other module I do this:

[lua]

local myFB = require(“myFB”)

myFB.login()

[/lua]

Naomi

thanks Naomi. Loos like the ‘facebook.login’ command  needs to be in the same file as the listener. I will give it a try.