lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]


Hi,

I am working on a messaging/collaborative application.  We are thinking about using either _javascript_ or Lua to allow third parties to (safely =) script the client.  The network model between the client and server is very asynchronous in that several requests can be outstanding in either direction.  In our existing code, we handle this by having a queue of objects waiting for their reply and a function is called in each when their data arrives.  For simplicity for the script users (who are less technically competent), I want the script to read something like this:

MsgObj = Msg.OpenByPath("SomePath")
FldData = MsgObj:GetFieldData()

Note that the first line involves a round trip to the server.  I am currently assuming the users will not be using coroutines and I am making the above work by lua_yield()ing back to where I called the interpreter, waiting for the open message to come back from the server, then lua_resume()ing back the message object.  The problem with this is if the user uses a coroutine, the yield in Msg.OpenByPath() won't yield all the way back out.  Is there some other way to break out of Lua execution all the way back to the initial call into the interpreter, leaving the state intact so I can resume it later once I have the available data?

(One thing I did look at was the downloading of files example in the PiL 2nd edition, however, I don't want to expect that level of competency from our users.  Also, I want control back in the C code as quickly as possible to handle other network and UI events that Lua isn't involved with.)

Thanks for any insights you might be able to provide,

James.
P.S. Sorry for the funny from name, I'm trying to fix that.