PDA

View Full Version : gip library callbacks



theguywiththefunnyhair
September 8th, 2006, 12:22 AM
Hi,
i have posted this question on the NR forum but since its the same in Girder i thought it cant hurt to ask here as well.
I am trying to use the gip library functions to query a server, i think i have a problem in the way i am trying to use the callback function because the way i have it set up the callback never gets called.
the code i'm using is
function HandleEPGdata(data,code)
if code == 16384 then
NetRemote.SetVariable("Dan.EPG.ConxStatus","Connection Lost") return
end
if code == 32768 then
if data == 0 then
NetRemote.SetVariable("Dan.EPG.ConxStatus","Connection Made")
else
NetRemote.SetVariable("Dan.EPG.ConxStatus","Connection Failed")
NetRemote.SetVariable("Dan.EPG.LastFailure",data)
end
return
end
if code == 1 then
NetRemote.MessageBox(data) return
end
NetRemote.SetVariable("Dan.EPG.ConxStatus","Callback made - no code match")
end;

function OpenEpgServConx()
NetRemote.SetVariable("Dan.EPG.ConxStatus","Open Socket func Executed")
EpgSock = gip.Open("127.0.0.1","1022")
EpgSock:Callback(4, HandleEPGdata)
end;


EpgSock is being created and i have a connection, but as i said my callback function HandleEPGdata() is not being used.

Can anyone see where i have gone wrong?

Thanks

Dan

Ron
September 8th, 2006, 05:41 AM
Dan, I think what is happening here is that the connection is connecting so fast that the callback gets set to late. I was afraid this might happen. I'm thinking about how to fix this. I'm about to get on a plane so I don't think I'll have something for you before monday.

theguywiththefunnyhair
September 9th, 2006, 06:42 PM
Hi Ron,
I think you can relax, firstly im actually doing this from NR and second after a reboot it works as expected,
thanks
Dan