View Full Version : NetRemote.lua
Rob H
March 5th, 2006, 01:19 AM
Here's the latest version of NetRemote.lua (for G4 and NR1.5)
This version should cache tables sent using NetRemote.SetVariable
The sending of tables is now run in the client's thread rather than the main thread.
Added NetRemote.RegisterConnectCallback etc.
mhwlng
March 5th, 2006, 09:25 AM
Rob,
I now see in girder logger :
error during call: ....netremote.lua:1471 attempt to index local 'client' (a boolean value)
when trying to send a table
Marcel
mhwlng
March 5th, 2006, 10:18 AM
Rob,
I need some advice..
Im trying to get a timer started for each client like so :
local function TimerUpdate (client)
...
...
NetRemote.ClientSetVariable(client:GUID(),"WEBSTATUSHTML",html);
end
local function clientconnect (client)
if client.userData.AutoUpdateTimer== nil then
client.userData.AutoUpdateTimer = gir.CreateTimer (function (...) return TimerUpdate (client) end,
function (...) return TimerUpdate (client) end,nil,1)
client.userData.AutoUpdateTimer:Arm (TimerUpdateInterval)
end
end
NetRemote.RegisterConnectCallback(clientconnect);
but... this doesn't quite work :D
TimerUpdate is called and client:GUID() contains a guid string, but the call to ClientSetVariable kills the timer for some reason and nothing is sent to NR...
do you know how I should approach this ?
Marcel
Rob H
March 5th, 2006, 10:34 AM
Here's a new version of NetRemote.lua
Rob H
March 5th, 2006, 10:35 AM
I can't think why ClientSetVariable would kill the timer. But since you have a client passed to your function anyway why not use client:SetVariable() instead?
mhwlng
March 5th, 2006, 11:06 AM
in this last version synchronization, when starting nr, doesn't work at all
(I do see 'synchronizing client' in girder...)
the version at the beginning of this thread had the same problem (but only for *existing* clients)
the version from the other thread didn't have this problem
Marcel
mhwlng
March 5th, 2006, 11:20 AM
another weird thing
in girder, I have some netremote events
and inside I changed from :
NetRemote.ClientSetVariable(pld2,"WEBPHONELOGHTML",phonehtml);
to
local x = comserv.GetConnection(pld1)
local guid = x:RemoteInstance()
local client = NetRemote.LookupClient(guid)
if client then
client:SetVariable("WEBPHONELOGHTML",phonehtml);
end
this works once, on the second time this event is executed, girder crashes...
Marcel
Rob H
March 5th, 2006, 01:18 PM
:(
I'll take a look at these tomorrow.
Rob H
March 6th, 2006, 05:24 AM
I'm afraid I can't reproduce your Girder crash here.
Can you give me a minimal CCF and GML that shows the problem?
mhwlng
March 6th, 2006, 05:58 AM
attached sample doesn't crash girder, but it doesn't work properly either :D
start girder,
start nr, first label is set : ok
press button, second label is set : ok
stop nr
start nr, first label is not set
press button, event is received by girder, but second label is not set
Marcel
Rob H
March 6th, 2006, 11:24 PM
D'oh. When the feedback thread is woken it checks to see if self.closing is true and shuts down if it is. I now keep the NRClient hanging around even when NR has gone. However, I'd forgotten to set self.closing to false, so when it came to restarting the feedback thread it was closing immediately, hence no further feedback!
Here's version 0.24 which I hope fixes all known problems (although since I can't reproduce the crash don't expect it will fix that one).
mhwlng
March 7th, 2006, 12:21 AM
I hope fixes all known problems
looks good :
* the sending/caching tables stuff works ok
* the RegisterConnectCallback stuff works ok
* the resyncing stuff when stopping/starting NR works ok
I still have a problem in girder, where I have an NR event and
this
local x = comserv.GetConnection(pld1)
local guid = x:RemoteInstance()
local client = NetRemote.LookupClient(guid)
if client then
client:SetVariable("WEBPHONELOGHTML",phonehtml);
end
causes weird problems :
start girder
start nr
send event from nr -> works fine
stop nr
start nr
send event from nr -> works fine
stop nr
start nr
send event from nr -> works fine
send event from nr -> crash girder
so the second time after starting nr, girder crashes.
but if you start/stop nr after each event, it also works fine ???
this always works fine :
NetRemote.ClientSetVariable(pld2,"WEBPHONELOGHTML",phonehtml);
but I can't reproduce this in a simple example :-?
(NR dies a lot on me, especially at startup or when using the new built-in webserver, but that's not your problem :D )
Marcel
Rob H
March 7th, 2006, 12:35 AM
Well, the first part is a huge relief.
I'm a little puzzled by the second part though :(
Can you try printing the guid and making sure that it's the same every time? Or save the last one in a global variable and compare them.
I'm just wondering whether perhaps you have two copies of NR running (or at least two client instances).
mhwlng
March 7th, 2006, 04:18 AM
I've managed to reproduce the problem in the above robtest sample
just add 'collectgarbage()' above the comserv stuff in the nr event in robtest.gml
press the togirder button twice in NR and kaboom :D ...
I removed collectgarbage from my code (I called this after doing some luasql odbc stuff) and the problem was gone...
Marcel
Rob H
March 7th, 2006, 08:56 AM
Thanks Marcel, I'll try to reproduce it here. It's amazing how much you come to rely on a broadband connection - been without mine for the last couple of hours and it's been hell!
Rob H
March 18th, 2006, 12:51 AM
Sorry - got sidetracked.
I can confirm that this happens here too.
I think this might be another one for Ron to look at.
mhwlng
March 19th, 2006, 07:26 AM
Rob,
there is an error in MakeTableSendCommand
you need to change
local changeVar = [[local...;]]
to
local changeVar = "local...;"
otherwise the changed variable doesn't get created...
Marcel
Rob H
March 19th, 2006, 07:35 AM
Oops, quite right - good catch.
mhwlng
April 4th, 2006, 12:36 AM
did anyone ever look at the collectgarbage issue ? which is still happening in the latest girder..
(see discussion and robtest sample a couple of posts back in this thread)
it's this line that causes a crash if it's preceded by a garbage collection
local x = comserv.GetConnection(pld1)
when this line is the first one executed then it doesn't crash...
local x = comserv.GetConnection(pld1)
print ('dostuff event received');
collectgarbage();
local guid = x:RemoteInstance()
local client = NetRemote.LookupClient(guid)
if client then
client:SetVariable("vvvv2","xxxxx");
end
Marcel
Rob H
April 4th, 2006, 12:57 AM
This is definitely one for Ron.
Ron
April 4th, 2006, 07:52 AM
Alright, checking today.
Ron
April 4th, 2006, 09:21 AM
confirmed.
Ron
April 4th, 2006, 09:40 AM
fixed. Also I found something that worried me and I need some feedback from the NetRemote.lua guys....
http://www.promixis.com/phpBB2/viewtopic.php?p=143807#143807
mhwlng
April 4th, 2006, 09:52 AM
it doesn't crash anymore, but
if garbage gets collected before the call to :
local x = comserv.GetConnection(pld1)
then x returns a nil, which also not ok (as you explain in the other thread you mention above)
Marcel
Ron
April 4th, 2006, 09:55 AM
Yep the connection gets closed hence you get nil. Something I can fix easily, but I want to check with everyone to make sure noone depends on the behaviour of closing the connection by nilling the variable.
mhwlng
April 4th, 2006, 10:00 AM
I would say, do as you suggest and don't kill the connection at a garbage collection, but I leave it up to Rob to comment on the impact on netremote.lua
Marcel
Ron
April 4th, 2006, 10:35 AM
fixed.
http://www.promixis.com/phpBB2/download.php?id=3162
mhwlng
April 4th, 2006, 10:49 AM
that looks ok,
thanks Ron
Marcel
Rob H
April 4th, 2006, 11:54 AM
Good news
Powered by vBulletin® Version 4.1.8 Copyright © 2012 vBulletin Solutions, Inc. All rights reserved.